0
我有什么(伪代码):轨道4 HABTM关系和额外的字段上的连接表
model Document
column :title
HABTM :users
model User
column :name
HABTM :documents
文件有用户(文件是批准,核准或没有),并在这方面加入表应为每个用户批准额外的列。
jointable
user_id, document_id, approved
1 , 1 , true
2 , 1 , false
我想主要是:
contract.approvers => returns users but with possibility to =>
contract.approvers.first.approve(:true) => and it updates JOINtable approve column to TRUE.
针对这一情况立即回答是可选的,会理解提供咨询架构太(也许我应该使用其他类型的关系?)。
连接表的仅此而已。如果你想要连接对象的列,你需要查看[has_many through](http://guides.rubyonrails.org/association_basics.html#the-has-many-through-association)关系。我的直觉告诉我,HABTM和has_many都不是这种情况的正确关系。我不知道我有足够的理解来提出更好的建议。 – 2015-02-10 03:57:24