I have a view with a form and i want to be able to process the button
selected in a controller - not sure how to do this. The form does not
map directly to a model - all I want to do is be able to pass back the
selected button and know which one it is.
So, i have a form and several radio buttons - the submit (not shown)
takes me to the process_answer action where I want to determine which
button was pressed
Also a newbie here, but I believe your data is in params[:radio] not
params[:answer].
So, try:
radio = params[:radio]
if radio.answer == “c”
or something like…
if params[:radio].answer == “c”
yb
Seamus Gilchrist wrote:
I have a view with a form and i want to be able to process the button
selected in a controller - not sure how to do this. The form does not
map directly to a model - all I want to do is be able to pass back the
selected button and know which one it is.
So, i have a form and several radio buttons - the submit (not shown)
takes me to the process_answer action where I want to determine which
button was pressed
However, I am still confused about the comments posted up top about
using something like
if params[:radio].answer == “c”
this is what i was previously trying to do, and i don’t understand why
it doesn’t work - it would seem like it should somehow because the param
values are stored in the hash and should be able to be pulled out of it.
assuming that i did a radio button
<%= radio_button “radio”, “answer”, “a” %> (A)
if I do a render(:text => params[:radio] I get answer a
so question is why can’t I access (or how do I access) just the a part
of the params[:radio]