Saturday, 17 August 2013

self referential association with polymorphic association

self referential association with polymorphic association

I have a User and Address models. A user may have many addresses and one
as default. I currently use this that works
# User.rb
belongs_to :default_address, class_name: "Address", foreign_key:
:default_address_id
Now I made the Address belongs_to :addressable, polymorphic: true.
My question is how to tell this default_address self association to use
the addressable instead of going directly to the Address class

No comments:

Post a Comment