I have a form that posts some values to a controller action.
How do get at the form values in my controller code?
For eaxmple, if my form has this field
<input type='text' name='foo' />
and I post to /controller/action
what is the code in the ‘action’ method to retreive that value of foo?
(2 attempts)
manveru answered:
def action if request.post? # check if you just got a POST request['foo'] # now you've got it :) request.params # list of all you've got end end
james answered:
Some discoveries:
The input fields must have a name attribute, not just an id.
Form POST data are available inside controller methods using request.params