# Help with polymorphic associations... the other way 'round

**URL:** <https://www.ruby-forum.com/t/help-with-polymorphic-associations-the-other-way-round/167923>\
**Category:** Rails\
**Created:** [May 14, 2009, 1:29am UTC](https://www.ruby-forum.com/t/help-with-polymorphic-associations-the-other-way-round/167923 "2009-05-14T01:29:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AdamV](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@AdamV](https://www.ruby-forum.com/u/AdamV)\
**Post date:** [May 14, 2009, 1:29am UTC](https://www.ruby-forum.com/t/help-with-polymorphic-associations-the-other-way-round/167923/1 "2009-05-14T01:29:17Z")

</div>

Good afternoon,

I have a situation were I have Container model which has\_many Item  
models (as a list). Now each Item can be either a TextItem (a chunk of  
HTML) or a FeedItem (some RSS Feed) – in the future I’ll add other  
Item types.

My first thought is to have the following:

class Container \< ActiveRecord::Base  
has\_many :items, :order =\> “position”  
end

class Item \< ActiveRecord::Base  
belongs\_to :container  
acts\_as\_list :scope =\> :container  
belongs\_to :content, :polymorphic =\> true  
end

class TextItem \< ActiveRecord::Base  
has\_one :item, :as =\> :content  
end  
class FeedItem \< ActiveRecord::Base  
has\_one :item, :as =\> :content  
end

My problem comes in at the view. None of these models are particularly  
complicated so I’d like to show and edit them inline with the  
container views. I’m really at a loss as to where to start, what I  
need to do to keep stuff connected, &c.

This seems like its a lot more complex than than standard nested form  
example so I’m hoping someone has an idea of where to start or even a  
link to some tutorial/article that will provide some illumination.
