Need HELP with RoR app using submit_to_remote

I think that this should be easy, but the solution escapes me. I am
using submit_to_remote and need to access the form parameters in the

In my view I have this as a sample so that I can generate the parameters
and see the hash.
<%= submit_to_remote 'Update Div', 'update', :url => {:action => 'do' }

Then the parameters that are returned include the form variables in this

Parameters: {"commit"=>"Create", "serializedstring"=>"", "order"=>{
"customer_id"=>"1", "name"=>"", "product_1"=>"1"},
"action"=>"do", "id"=>"order_params", "controller"=>"orders", "Update

How can I access the parameters from the form such as name, customer_id,
etc to perform some function in the controller?


This works the same as it would if you had simply submitted the form
in the usual manner rather than
via remote, you can access them through the params hash. So you can
simply say something like

if params[:name] == "spammer"
    error_code = "OH NOES!!!! SPAMMERS!.


PeteSalty wrote:

if params[:name] == "spammer"
    error_code = "OH NOES!!!! SPAMMERS!.

Makes perfect sense to me and I was trying to access the variables this
way, but it's not working. This again is all just to see the output.

In my controller I have
  def do
    @cust_id = params[:customer_id]
    render :update do |page|
      page.replace_html 'updateDiv', :partial => 'test'

My partial has this
customer id: <%=h @cust_id %> - id

My output is
customer id: - id

Any ideas on what I'm missing?

Try, e.g.,




Roy Pardee wrote:


Worked great! thanks.

Can I take this one step further to insert these values into the db?
The way that this works is a user starts to fill out a form and then
needs to open up a pop-up window to choose more values. The problem
that I ran in to is that if it's a new order, then there's no order id
to associate with the pop-up window values so I want to capture what's
already been completed on the form, insert that, and use the new record
id value with the pop-up value.

Is there an elegant way to loop through the order values without naming
each key and value pair?


I *think* so--have a look at these railscasts for a possible method:

Not sure how the pop-up form will interact w/that method--hopefully
someone more experienced can advise there.