# Polymorphic association and has\_one retrieval issues

**URL:** <https://www.ruby-forum.com/t/polymorphic-association-and-has-one-retrieval-issues/185923>\
**Category:** Rails\
**Created:** [March 29, 2010, 9:57am UTC](https://www.ruby-forum.com/t/polymorphic-association-and-has-one-retrieval-issues/185923 "2010-03-29T09:57:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 29, 2010, 9:57am UTC](https://www.ruby-forum.com/t/polymorphic-association-and-has-one-retrieval-issues/185923/1 "2010-03-29T09:57:00Z")

</div>

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.
