On Jan 25, 2014, at 11:45 PM, Martin Sloan wrote:
> Blaine,
>
> Thanks for the post. The book I'm reading followed up the basic join example (many-to-many) with a 'rich' join (has_many :through). From what I understand there's a scenario for both and they're similar but there are differences. In the book's example the articles and categories tables are 'meeting up' at the articles_categories table and not 'going through' to reference another table.
HABTM joins are used for "dumb" joins, where you want a two-way relationship between two tables that does not carry any further information about its connection. Most real-world connections aren't that dumb, and so the general advice is to use a HMT connection to "educate" that join. Person -> has many Clubs -> through Membership would be a simple example. Membership can have a member type picker, a date joined, date kicked out of the club for unsportsman-like conduct, whatever other "smart" attributes the real relationship might need to carry.
Walter
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to
rubyonra...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/734daa7f-7ccb-40ea-bc5c-a81dfb4cb021%40googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.