Ruby on Rails Monday, November 1, 2010

Yup, then like Marnen said, Person should belong to Item:

belongs_to :item, :polymorphic => true

In your migration, you can use:

t.references :item, :polymorphic => true

Which will create item_type and item_id columns.

Then each class A, B, and C can have one person:

has_one :person, :as => :item

--
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