Forum: Ruby on Rails observe_field - returning weird key/value pair

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sergio T. R. (Guest)
on 2009-05-15 18:18
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!
Sergio T. R. (Guest)
on 2009-05-15 18:34
just as a hint..

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


"product_section"=>{"product_section_id"=>"3"}
mike (Guest)
on 2009-05-16 00:33
(Received via mailing list)
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 :)

2009/5/15, Sergio R. <removed_email_address@domain.invalid>:
> 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
Tom Z Meinlschmidt (Guest)
on 2009-05-16 02:28
(Received via mailing list)
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
===============================================================================
This topic is locked and can not be replied to.