views:

30

answers:

1

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. 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?

+1  A: 

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

John Topley