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>

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.