Re: polymorphic association vs HABTM

Thorsten Mueller
Mon, 18 Feb 2008 15:32:13 -0000

has not much to do with each other

you would use polymorphic associations if you want to attach some kind
of information and functionality to several other tables/models
say for example you want to add image uploads to your app (which is some
social thing for car fans as example).

users can upload images of themselves
or
they can upload images of their cars

the data stored and upload functionality is just the same for cars or
users, so with polymorphic assocs you can just make both of them
imagable

habtm relations just define, that two tables are related in a they, that
each of them can be linked to many of the other kind

author has many books
books have many authors
--
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---