I''m new to Ruby, Rails and Ajax and I''m trying to do something seemingly simple. I am trying to use a value someone supplies in a form in another form that is dynamically generated using Ajax. I have the following code: <div id="race_table"> </div> <%= form_remote_tag(:update => "race_table", :url => { :action => "update_races" }) %> <table> <tr> <td>Ruleset:</td> <td><%= select(:post, :ruleset, @rulesets) %></td> </tr> <tr> <td colspan="2"><%= submit_tag "Find Races" %></td> </tr> </table> <%= end_form_tag %> Which has been changed umpteen times, but this is how it stands now and I''m thinking it should be accurate. @rulesets contains an array of arrays such that it prints something like <option value="1">Ruleset #1</option> Then I have the update_races action of the same module. It does several things but most notably (and stripped down at the moment it does) @ruleset = params[:ruleset] || 11 render :layout => false Then I have the update_races.rhtml file which does lots of things but ultimately does: <%= @ruleset %> And ruleset is ALWAYS 11. For some reason params[:ruleset] is always nil. My browser is Firefox 2.0.0.6 Please help :) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Try params[:post][:ruleset] If you use select then the first parameter is the object that is being worked with and the second parameter is the attribute/method being addressed. What I would suggest you do is put this line of code in your controller action logger.info params.inspect This will write the contents of params to your development log. Go check it out - then you can see how params is structured. You will see that params in a hash, and in params is a "post" => {}. The hash that the "post" key is pointing to will contain the ruleset symbol. so you should see {"post" => {:ruleset => 5}, other params go here} cheers Ivor On 9/10/07, Chris <cpeters.email-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > I''m new to Ruby, Rails and Ajax and I''m trying to do something > seemingly simple. I am trying to use a value someone supplies in a > form in another form that is dynamically generated using Ajax. > > I have the following code: > > <div id="race_table"> > > </div> > > <%= form_remote_tag(:update => "race_table", :url => { :action => > "update_races" }) %> > <table> > <tr> > <td>Ruleset:</td> > <td><%= select(:post, :ruleset, @rulesets) %></td> > </tr> > <tr> > <td colspan="2"><%= submit_tag "Find Races" %></td> > </tr> > </table> > <%= end_form_tag %> > > Which has been changed umpteen times, but this is how it stands now > and I''m thinking it should be accurate. @rulesets contains an array > of arrays such that it prints something like <option value="1">Ruleset > #1</option> > > Then I have the update_races action of the same module. It does > several things but most notably (and stripped down at the moment it > does) > > @ruleset = params[:ruleset] || 11 > render :layout => false > > Then I have the update_races.rhtml file which does lots of things but > ultimately does: > > <%= @ruleset %> > > And ruleset is ALWAYS 11. For some reason params[:ruleset] is always > nil. My browser is Firefox 2.0.0.6 > > Please help :) > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks so much! Not only did that solve my problem but teaching me about the logger will help me immensely to troubleshoot future problems :) Chris On Sep 10, 1:04 am, "Ivor Paul" <ivorp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Try params[:post][:ruleset] > > If you use select then the first parameter is the object that is being > worked with and the second parameter is the attribute/method being > addressed. > > What I would suggest you do is put this line of code in your controller > action > > logger.info params.inspect > > This will write the contents of params to your development log. Go check it > out - then you can see how params is structured. You will see that params in > a hash, and in params is a "post" => {}. The hash that the "post" key is > pointing to will contain the ruleset symbol. so you should see {"post" => > {:ruleset => 5}, other params go here} > > cheers > Ivor > > On 9/10/07, Chris <cpeters.em...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I''m new to Ruby, Rails and Ajax and I''m trying to do something > > seemingly simple. I am trying to use a value someone supplies in a > > form in another form that is dynamically generated using Ajax. > > > I have the following code: > > > <div id="race_table"> > > > > </div> > > > <%= form_remote_tag(:update => "race_table", :url => { :action => > > "update_races" }) %> > > <table> > > <tr> > > <td>Ruleset:</td> > > <td><%= select(:post, :ruleset, @rulesets) %></td> > > </tr> > > <tr> > > <td colspan="2"><%= submit_tag "Find Races" %></td> > > </tr> > > </table> > > <%= end_form_tag %> > > > Which has been changed umpteen times, but this is how it stands now > > and I''m thinking it should be accurate. @rulesets contains an array > > of arrays such that it prints something like <option value="1">Ruleset > > #1</option> > > > Then I have the update_races action of the same module. It does > > several things but most notably (and stripped down at the moment it > > does) > > > @ruleset = params[:ruleset] || 11 > > render :layout => false > > > Then I have the update_races.rhtml file which does lots of things but > > ultimately does: > > > <%= @ruleset %> > > > And ruleset is ALWAYS 11. For some reason params[:ruleset] is always > > nil. My browser is Firefox 2.0.0.6 > > > Please help :)--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Reasonably Related Threads
- strange problem with ipfw and rc.conf
- [Bug 1758] New: Design flaw in chain traversal
- form_remote_tag params not passed .. PLEASE help!
- [Bug 1188] New: nft fails to parse own output; unable to save-restore active state
- Arules: R Crashes when running eclat with tidLists=TRUE