开发者

What is the convention when relevant data needs to be stored in a join table?

Suppose you have a data model that is something like

class Question

has_and_belongs_to_many :choices

end

Now suppose, on that choices model, there is a position column.开发者_C百科 What is the best way to access that information without having horrible messy queries / models?

The beauty of has_and_belongs_to_many is that it keeps things concise and simple. Is there a way to accomplish that, but still have access to my questions_choices.position?


"You should use has_many :through if you need validations, callbacks, or extra attributes on the join model."

  • A Guide to Active Record Associations
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜