views:

6

answers:

0

This question is regarding the html form in RSpec book (beta version b15_0), page: 301. The best way I could figure for that problem is this:

<p>
  <%= f.label :genres %><br />
  <%- @genres.each do |genre| %>
    <%= check_box_tag(genre.name, genre.id) %>
    <%= label_tag(genre.name) %><br />
  <%- end %>
</p>

This forces me to check for the param[:comedy] and then assign param[:genre] (or in model, genre_id) to the id. So, depending on how many genres are present (hopefully very small, else the design of the html form is not good) then doing this way looks too bad.

Does anyone have a better way of representing the checkboxes in that example?