For my first rails app, I''m building a web page that will list some
restaurants and then have the user rate them from from 1 to 5 using 5
radio buttons. The view code looks like:
<h3>Ratings:</h3>
<form action="save_ratings" method="post">
<table>
<tr>
<th>Restaurant</th>
<% for rating_option in [1,2,3,4,5] -%>
<th><%=h rating_option.to_s -%></th>
<% end -%>
</tr>
<% for user_rating in @ratings -%>
<tr>
<td><%=h user_rating.restaurant.name -%>: </td>
<% for rating_option in [1,2,3,4,5] -%>
<td><%= radio_button(:user_rating, :rating, rating_option)
-%></td>
<% end -%>
</tr>
<% end -%>
</table>
<input type="submit" value="Save">
</form>
Where @ratings contains an array of objects from find(:all), and I want
to assign the value of the radio button to user_rating.rating (an int
field in the table).
This code links all the radio buttons for all rows in one group. How
can I assign a group of radio buttons to a specific row? Also, where is
the documentation on the options hash for radio_button?
Thanks,
Aaron
--
Posted via http://www.ruby-forum.com/.