Jun'uary
Jan'uary » 日志 » habtm and has_many :through
habtm and has_many :through
Jan 发表于 2008-04-23 17:26:15
Most articles on the web give ppl an impression that habtm(has_and_belongs_to_many) is outdated and you should use has_many :through in many-to-many relationship between ActiveRecord models. I'd say that's wrong.
In fact habtm is more closer to has_many without :through than has_many :through, like it will add #{collection}_ids method but has_many :through won't. And habtm is NOT outdated, has_many :through is not a replacement of habtm. You should restrict yourself to use has_many :through only when you have to model the join table in the middle, in any other case, habtm is the better choice.
In fact habtm is more closer to has_many without :through than has_many :through, like it will add #{collection}_ids method but has_many :through won't. And habtm is NOT outdated, has_many :through is not a replacement of habtm. You should restrict yourself to use has_many :through only when you have to model the join table in the middle, in any other case, habtm is the better choice.
相关日志:
收藏:
QQ书签
del.icio.us
订阅:
Google
抓虾
