I currently have two different models: User and Project . The User model has three types of users — owners, contractors, and customers. I want to assign several contractors to one project. I am trying to do this with the has_many :through association, for example:
Class User has_many :assignments has_many :projects, :through => :assignments Class Project has_many :assignments has_many :contractors, :through => :assignments Class Assignment belongs_to :user belongs_to :project
My problem is using contractor_id in the assignments table instead of user_id .
In my assignments table, I currently have the columns contractor_id and project_id . Everything seems to work if I use user_id instead, but this will cause the situation to be pretty dirty in my views.
How to do it?
ruby-on-rails ruby-on-rails-3
Andy bas
source share