Hello. I''m trying to have a select box in one of my views be observed for change and have the value of the select box be accessible via params[:name] in my controller. However, no matter what I try the select parameters sent back to the server are always in params as "value => nil". That makes it quite difficult to get the value of the select box since value is different for every selection. Here is what I''ve tried. 1. Simple HTML approach <select id="bird" name="bird"> <option value="3">Bald Eagle</option> </select> <%= observe_field("bird", :url => url(:avian, :hunt)) %> 2. Rails approach <%= collection_select("avian", "avian_id", Avian.find(:all).sort, :avian_id, :description, :include_blank => true) %> <%= observe_field("avian_avian_id", :url => url(:avian, :hunt)) %> In case 1 the parameters related to the select that appear with params are "3 => nil". Similar feedback for case 2. In neither case is the select in a form. I figured that is not necessary since my HTML is valid and the observer is monitoring the select. I''ve tried wrapping the select in a simple <form></form> but no luck. Obviously I am missing something because I cannot find posts related to this topic in this forum or elsewhere on the ''net. I''m trying to take the simplest approach here. Can someone please clue me in? Thanks! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Have u tried using the :with argument? <%= observe_field ''avian_avian_id'', :url => url(:avian, :hunt), :with => ''name'' %> http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M000966 Regards, Jabbslad On Feb 21, 2:59 pm, Chris Stump <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello. I''m trying to have a select box in one of my views be observed > for change and have the value of the select box be accessible via > params[:name] in my controller. However, no matter what I try the select > parameters sent back to the server are always in params as "value => > nil". That makes it quite difficult to get the value of the select box > since value is different for every selection. > > Here is what I''ve tried. > > 1. Simple HTML approach > > <select id="bird" name="bird"> > <option value="3">Bald Eagle</option> > </select> > <%= observe_field("bird", :url => url(:avian, :hunt)) %> > > 2. Rails approach > > <%= collection_select("avian", "avian_id", Avian.find(:all).sort, > :avian_id, :description, :include_blank => true) %> > <%= observe_field("avian_avian_id", :url => url(:avian, :hunt)) %> > > In case 1 the parameters related to the select that appear with params > are "3 => nil". Similar feedback for case 2. In neither case is the > select in a form. I figured that is not necessary since my HTML is valid > and the observer is monitoring the select. I''ve tried wrapping the > select in a simple <form></form> but no luck. > > Obviously I am missing something because I cannot find posts related to > this topic in this forum or elsewhere on the ''net. I''m trying to take > the simplest approach here. Can someone please clue me in? Thanks! > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Chris Stump
2008-Feb-22 03:52 UTC
Re: Select option passes value => nil, not name => value
That did the trick, thank you. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---