Active scaffold polymorphic model

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs