3

I'm displaying a table of radio buttons, each of which corresponds to a recipe with a unique id. I'm using a submit tag to submit exactly which radio button was pressed, indicating which recipe was selected. I'm trying to pass the id to my controller to make some queries/form fields. I'm having trouble actually passing the id. Can someone help me out, I'm a Ruby newbie? Thanks!

<%= form_tag(:action => 'chooseOption') do %>
<%= submit_tag("Show Recipe", :class => 'action show') %>
<%= submit_tag("Delete Recipe", :class => 'action delete') %>

<td><%= radio_button_tag 'recipe', recipe, @recipe == recipe %></td>
  <td>recipe.recipe_name</td> 
  <td>recipe.total_calories</td> 
  .....all the other fields
</td>
lordmarinara
  • 267
  • 5
  • 15

1 Answers1

2

See

http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-radio_button

Also

http://guides.rubyonrails.org/form_helpers.html

Section 1.3.2, radio_button_tag

And last but not least,

Labels for radio buttons in rails form

Community
  • 1
  • 1
varatis
  • 14,494
  • 23
  • 71
  • 114