Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

form_for params

I need to submit a form to an external URL, so I have this:

form_for(@task, :url => "https://www.external.com/Submit") do |f|)
    <%= f.hidden_field :assignmentId, :value => @assignment %>
    <%= link_to image_tag(@imagelocation) %>
....

I am using form_for, because I need to access to my controller variables.

The external server looks for a param, assignmentId. When the form is submitted, the param is actually available as

params[:task][:assignmentId]

which fails to pass validation on the external server.

How do I resolve this? How do I access variables from my controller and pass 'naked' params to the external server?

[edit] Here's what the submit params looks like

utf8=%E2%9C%93&_method=put&task%5BassignmentId%5D=2LVQ39Z0B6UWI8NXYWJTYRKGQXIMXN&task%5Boutput%5D=carpet&commit=Post

I want it to not have the task referenced.

like image 898
Siddharth Ram Avatar asked Mar 25 '13 02:03

Siddharth Ram


1 Answers

Use hidden_field_tag instead of f.hidden_field. Btw, if you want this field to store assignment's id, you should use @assignment.id, not just @assignment.

<%= hidden_field_tag :assignmentId, @assignment.id %>
like image 112
Ilya Khokhryakov Avatar answered Sep 21 '22 23:09

Ilya Khokhryakov