class Address < ActiveRecord::Base
belongs_to :addressable, :polymorphic => true
end
class Client < ActiveRecord::Base
has_one :address, :as => :addressable
end
Now I''am able to create a correct entry in the db for address with
addressable_id = 1#client_id
addreassable_type = ''Client''
but when I retrieve
client = Client.find(1) --> return client instance with id =1
address = client.address -> address is not nil
BUT
address.attributes == nil
Somehow I can''t retrieve the address back using association
client.address even though I could create it.
I must be missing something simple. Would appreciate any tips.
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.