ruby on rails - Having object belong_to two different types of the same model (e.g. user-typea and user-typeb)? -


basically trying make project model have foreign key references user-typea , user-typeb , belongs them both. i.e.

#models/project.rb belongs_to :typea, class_name: "user", foreign_key: "typea_id" belongs_to :typeb, class_name: "user", foreign_key: "typeb_id"  #models/user.rb has_many :projects 

is best way it? or best have separate model user-typea , user-typeb?


Comments