which is the better way to do many-to-many association?
Hey, everyone, in my last question link, In the answer which is given by Trip, he said:
But that join table in Rails does not have to be开发者_运维问答 created in a migration. It can be done exclusively in the models.
should I use a join table like my code or without join table by using :though? Which is the right way to go?
It depends on the requirement. See, primarily you should go with has_and_belongs_to_many as it does not need an extra model.
But if you need any other extra information to be saved in the table also along with association, then you must go with has_many :through option
精彩评论