I’m trying to pass a value from a radio button group in my view to a method in my controller. I’ve looked up many different ways of doing this and I get the same result, nil.
So far I have:
In view
<div id = "oilchange_buttons">
<br><%= radio_button_tag 'oilchange', '0' %> Complete
<%= radio_button_tag 'oilchange', '1' , true %> Pending
</div>
<%= link_to 'Update', :remote => true, :action => "there" , :submit => 'oilchange_buttons' , > :id=> @huntingtonflatbedboxtruck %>
In controller
def there
if params[:oilchange] == '0'
Do stuff
end
At this point in the controller all I get is nil rather than a value. I’m stuck and have no clue what else to try. I’m still fairly new to rails, I’m probably missing something fundamental. Thanks!
You need
form_tag. If this is your first time to create any form in Rails, I’d suggest you read the link @Veger provided and http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-form_tag.You need
:remoteforform_tagthe method, not forlink_to().