Hi,
I'm wondering how to write or read an additional attribute in the
through table.
Beside the foreign key, I have in the 'Responsible' table an additional
data field 'type' to set the kind of 'responsibility' for the company.
Can I access it from the user or company model?
class User < ActiveRecord::Base
has_many :responsibles
has_many :companies, :through => :responsibles
end
class Company < ActiveRecord::Base
has_many :responsibles
has_many :users, :through => :responsibles
end
class Responsible < ActiveRecord::Base
# datafields: user_id, company_id, type:string
belongs_to :user
belongs_to :company
end
Thanks!
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment