Ruby on Rails Monday, November 1, 2010

dpal wrote in post #958489:
> I have a relationship were a person can have 1 item, and this item is
> either a A || B || C.
> Rails supports the belongs_to polymorphic, but I don't see how can a
> Model have one of several models as opposed to belong_to one of
> several models.
> Can anyone tell me how to map this relationship ?

You want Person belongs_to Item. Remember, belongs_to is used for the
table that contains the foreign key field.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org

--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment