Observe_field - returning weird key/value pair

i am currently having a very strange problem with observe_field.

i have a select box that looks like this:

<%= select “product_section”, “section”, ProductSection.find(:all, :order => “title ASC”).collect { |p| [p.title, p.id]}, { :include_blank => true } %>

i want to observe the drop down box to have an action happen whenever
the value of the dropdown is changed…

i have added the following code to observe the field:

<%= observe_field(:product_section_section, :update => ‘attribute_data’,
:url => ‘insert_attributes’, :frequency => 1) %>

notice the naming of the field_id in observe field. this does work…

the problem is, when i make a selection, the parameters that get passed
look like this:

params = {“7”=>nil,
“authenticity_token”=>“f245fed70e1760739566121d68a8340a154e086a”,
“action”=>“insert_attributes”, “controller”=>“admin”}

that key/value of “7”=>nil is the one i am interested in… but it seems
like it’s backward. i am thinking i should get a key/value passed that
looks more like:

‘“product_section”=>“7”’

anyone have any idea what i am doing wrong?

thanks!

just as a hint…

when i submit this form, the select box value looks like this:

“product_section”=>{“product_section_id”=>“3”}

You can omit frequency if u just want to trigger on change. To pass
arbitrary parameters use the :with option like described in the rails
api for link_to_remote. I would be more specific if i weren’t on my
cell in berlin underground :slight_smile:

2009/5/15, Sergio R. [email protected]:

the value of the dropdown is changed…
the problem is, when i make a selection, the parameters that get passed

‘“product_section”=>“7”’

anyone have any idea what i am doing wrong?

thanks!

Posted via http://www.ruby-forum.com/.


Von meinen Mobilgerät aus gesendet

Sergio,

show me the generated html of select and observer…

t

Sergio R. wrote:

params = {“7”=>nil,
anyone have any idea what i am doing wrong?

thanks!

Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

  • experienced RoR/PHP freelancer, available for hire

www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz