Reputation: 4975
I'm trying to use some radio buttons to be selected and use the parameter as a find condition for my model... SO far I have. View
<% form_tag do %>
<p> <%= radio_button_tag :interest, "apple" %> Apple </p>
<p> <%= radio_button_tag :interest, "orange" %> Orange </p>
<p> <%= radio_button_tag :interest, "peach" %> Peach </p>
<p> <%= radio_button_tag :interest, "banana" %> Banana </p>
<p> <%= submit_tag 'Choice' %> </p>
<% end %>
<p>Result: <%= @result %></p>
how do i get @result = param[?], so it displays the value of the radiobuttons?
Eventually, I would to put the parameter into a find conditions where it would be something Fruit.find(:all, :type => "name LIKE ?", param[?])
I looked at Radio buttons on Rails but I didnt know how to make is a form so you I could read the parameter value
Upvotes: 2
Views: 13356
Reputation: 68046
You can always look at generated html. In this case (if you don't use prefixes), it should be like <input name="interest" ... >
. So, you can fetch parameter values by params[:interest]
.
on comment
Pure html. You will find something similar if you check html generated by your rails tags.
<input name="interest" value="apple" type="radio"> Apple <br/>
<input name="interest" value="orange" type="radio"> Orange <br/>
...
Upvotes: 4