# Need HELP with RoR app using submit\_to\_remote

**URL:** <https://www.ruby-forum.com/t/need-help-with-ror-app-using-submit-to-remote/137635>\
**Category:** Rails\
**Created:** [May 14, 2008, 10:06pm UTC](https://www.ruby-forum.com/t/need-help-with-ror-app-using-submit-to-remote/137635 "2008-05-14T22:06:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![newrubygirl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e274bd/32.png) [@newrubygirl](https://www.ruby-forum.com/u/newrubygirl)\
**Post date:** [May 14, 2008, 10:06pm UTC](https://www.ruby-forum.com/t/need-help-with-ror-app-using-submit-to-remote/137635/1 "2008-05-14T22:06:43Z")

</div>

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  
controller.

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  
format:

Parameters: {“commit”=\>“Create”, “serializedstring”=\>"", “order”=\>{  
“customer\_id”=\>“1”, “name”=\>"", “product\_1”=\>“1”},  
“authenticity\_token”=\>“4e652db61e8fc197f148898ecb1fd926739a9359”,  
“action”=\>“do”, “id”=\>“order\_params”, “controller”=\>“orders”, “Update  
Div”=\>“update”}

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

THANKS!

---

<div class="post-metadata">

**Author:** ![newrubygirl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e274bd/32.png) [@newrubygirl](https://www.ruby-forum.com/u/newrubygirl)\
**Post date:** [May 15, 2008, 12:06am UTC](https://www.ruby-forum.com/t/need-help-with-ror-app-using-submit-to-remote/137635/2 "2008-05-15T00:06:24Z")

</div>

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!.  
end

Dale

On May 14, 1:06 pm, Becca G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![newrubygirl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e274bd/32.png) [@newrubygirl](https://www.ruby-forum.com/u/newrubygirl)\
**Post date:** [May 15, 2008, 12:20am UTC](https://www.ruby-forum.com/t/need-help-with-ror-app-using-submit-to-remote/137635/3 "2008-05-15T00:20:55Z")

</div>

PeteSalty wrote:

> if params[:name] == “spammer”  
> error\_code = "OH NOES!!! SPAMMERS!.  
> end

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’  
end  
end

My partial has this  
customer id: \<%=h @cust\_id %\> - id

My output is  
customer id: - id

Any ideas on what I’m missing?

---

<div class="post-metadata">

**Author:** ![newrubygirl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e274bd/32.png) [@newrubygirl](https://www.ruby-forum.com/u/newrubygirl)\
**Post date:** [May 15, 2008, 4:26pm UTC](https://www.ruby-forum.com/t/need-help-with-ror-app-using-submit-to-remote/137635/4 "2008-05-15T16:26:19Z")

</div>

Roy P. wrote:

> params[:order][“customer\_id”]

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?

THANKS!

---

<div class="post-metadata">

**Author:** ![newrubygirl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e274bd/32.png) [@newrubygirl](https://www.ruby-forum.com/u/newrubygirl)\
**Post date:** [May 15, 2008, 2:27am UTC](https://www.ruby-forum.com/t/need-help-with-ror-app-using-submit-to-remote/137635/5 "2008-05-15T02:27:34Z")

</div>

Try, e.g.,

params[:order][“customer\_id”]

HTH,

-Roy

---

<div class="post-metadata">

**Author:** ![newrubygirl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e274bd/32.png) [@newrubygirl](https://www.ruby-forum.com/u/newrubygirl)\
**Post date:** [May 15, 2008, 5:59pm UTC](https://www.ruby-forum.com/t/need-help-with-ror-app-using-submit-to-remote/137635/6 "2008-05-15T17:59:00Z")

</div>

I _think_ so–have a look at these railscasts for a possible method:

> **[\#73 Complex Forms Part 1 - RailsCasts](http://railscasts.com/episodes/73-complex-forms-part-1)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

> **[\#74 Complex Forms Part 2 - RailsCasts](http://railscasts.com/episodes/74-complex-forms-part-2)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

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