Does the new has_many :through and belongs_to :through obsolete (well, replace and essentially deprecate) has_and_belongs_to_many? Joe -- Posted via http://www.ruby-forum.com/.
Not necessarily. We don''t always have a rich association. It might be enough to know that A has many of B, without needing another model C to describe the association. Or put another way, if we didn''t have habtm, we couldn''t associate A to B without creating a C, even if C is meaningless. On 3/28/06, Joe <joe@yahoo.com> wrote:> Does the new has_many :through and belongs_to :through obsolete (well, > replace and essentially deprecate) has_and_belongs_to_many? > > Joe > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 3/28/06, Kenneth Lee <klee@klmn.net> wrote:> > Not necessarily. We don''t always have a rich association. It might > be enough to know that A has many of B, without needing another model > C to describe the association.I''m trying to get this clear in my mind as well. Are you saying that if the bridge table C has additional fields that are unique to the association, then that would be a candidate for the has_many :through and belongs_to :through construct? Otherwise, use the habtm construct? Or put another way, if we didn''t have> habtm, we couldn''t associate A to B without creating a C, even if C is > meaningless. > > On 3/28/06, Joe <joe@yahoo.com> wrote: > > Does the new has_many :through and belongs_to :through obsolete (well, > > replace and essentially deprecate) has_and_belongs_to_many? > > > > Joe > > > > -- > > Posted via http://www.ruby-forum.com/. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Best Regards, -Larry "Work, work, work...there is no satisfactory alternative." --- E.Taft Benson -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060328/67e4f19e/attachment-0001.html
Larry Kelly wrote:> Are you saying that if the bridge table C has additional fields that are > unique to the association, then that would be a candidate for the has_many > :through and belongs_to :through construct? Otherwise, use the habtm > construct?That''s a good start on it. has_many :through lets you have rich associations (read and write atrributes in the join model), and it also lets you eagerly load data using :includes. If all you have is a simple join table, then habtm might be fine for you. Also, habtm is still necessary for dealing with legacy database schemas that don''t have a primary key on the join table. I''ve been writing about has_many :through associations on my aptly named blog. You might find some stuff there worth reading if you''re interested in them. -- Josh Susser http://blog.hasmanythrough.com -- Posted via http://www.ruby-forum.com/.