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! -- 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 -~----------~----~----~----~------~----~------~--~---
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 Girl <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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! > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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? -- 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 -~----------~----~----~----~------~----~------~--~---
Try, e.g., params[:order]["customer_id"] HTH, -Roy -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Becca Girl Sent: Wednesday, May 14, 2008 1:07 PM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] 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 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! -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Roy Pardee 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! -- 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 -~----------~----~----~----~------~----~------~--~---
I *think* so--have a look at these railscasts for a possible method: http://railscasts.com/episodes/73 http://railscasts.com/episodes/74 Not sure how the pop-up form will interact w/that method--hopefully someone more experienced can advise there. -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Becca Girl Sent: Thursday, May 15, 2008 7:26 AM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Re: Need HELP with RoR app using submit_to_remote Roy Pardee 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! -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---