form_remote_tag not providing params in Ajax

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"> &nbsp; </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 :slight_smile:

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

Thanks so much! Not only did that solve my problem but teaching me about the logger will help me immensely to troubleshoot future problems :slight_smile:

Chris