# Active scaffold polymorphic model

**URL:** <https://www.ruby-forum.com/t/active-scaffold-polymorphic-model/112851>\
**Category:** Rails\
**Created:** [August 23, 2007, 9:34pm UTC](https://www.ruby-forum.com/t/active-scaffold-polymorphic-model/112851 "2007-08-23T21:34:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![apie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecccb3/32.png) [@apie](https://www.ruby-forum.com/u/apie)\
**Post date:** [August 23, 2007, 9:34pm UTC](https://www.ruby-forum.com/t/active-scaffold-polymorphic-model/112851/1 "2007-08-23T21:34:51Z")

</div>

Hi

I am trying to use active scaffold to build a polymorphic model .

I have a number of models that can be featured and I have a Feature  
model  
that belongs\_to :item, :polymorphic =\> true

In my config.columns I include :item\_type and item\_id, I also added  
:item\_name to show the name of the record in the form.  
In the form, when a type of model is selected I populate the select box  
for  
item\_name with with the names of the relevant records with the id of  
each as  
the value. I set the id of the select box to item\_id instead of  
item\_name as  
I have figured out that item\_id is ignored by ActiveScaffold in the  
views.  
Can I turn this off so that it shows the id?

Params is now passed with :record =\> {:item\_type =\> “SelectedType”,  
:item\_id  
=\> id corresponding to the name chosen} which should correctly save the  
record, however, the record is saved without the item\_id. If I use the  
before\_create\_save(record) and before\_update\_save(record) functions and  
do  
record.item\_id = params[:record][:item\_id] it works.

I have found in the documentation that only whitelisted fields are  
saved,  
however, I did include :item\_id in the config.columns…

I would appreciate it if anyone can provide some insights as to why the  
item\_id isn’t saved correctly.

Regards  
Ivor  
[www.codevader.com](http://www.codevader.com)
