# Polymorphic with multiple associations to same model

**URL:** <https://www.ruby-forum.com/t/polymorphic-with-multiple-associations-to-same-model/150175>\
**Category:** Rails\
**Created:** [October 5, 2008, 12:43pm UTC](https://www.ruby-forum.com/t/polymorphic-with-multiple-associations-to-same-model/150175 "2008-10-05T12:43:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![reynar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e99b99/32.png) [@reynar](https://www.ruby-forum.com/u/reynar)\
**Post date:** [October 5, 2008, 12:43pm UTC](https://www.ruby-forum.com/t/polymorphic-with-multiple-associations-to-same-model/150175/1 "2008-10-05T12:43:22Z")

</div>

Hi,

Is there a recommended way to handle the following deviance from the  
standard polymorphic arrangement?

Specifically the fact that SalesOrder must refer to multiple  
addresses? Ignoring the polymorphic aspect I would normally just have:

## – belongs\_to :delivery\_address, :class\_name =\> ‘Address’ belongs\_to :billing\_address, :class\_name =\> ‘Address’

However this does tend to end up with a slightly messy address table  
with mixed reference methods, and it sounds more correct for the  
address to belong to ‘something’ rather than the other way around. Can  
this be solved or is this the limit?

class Address \< ActiveRecord::Base  
belongs\_to :addressable, :polymorphic =\> true  
end

class Customer \< ActiveRecord::Base  
has\_many :addresses, as =\> :addressable  
end

class SalesOrder \< ActiveRecord::Base  
has\_one :delivery\_address, as =\> :addressable  
has\_one :billing\_address, as =\> :addressable  
end

Thanks, Andrew
