I am trying to display checkboxes on a form that show all of the contacts for a user, so that the user can then select the contacts required. I have done this on the form so far, which displays the checkboxes but with no value:
<% @contacts.each do |contact| %>
<% if contact.user.id == User.find(session[:user_id]).id %>
<%= f.check_box :to %>
<% end %>
<% end %>
But when I try to change the line <%= f.check_box :to %>
to <%= f.check_box :to, contact.email %>
to show the email address of the contact I get the error:
undefined method `merge' for "email@123.com":String
Is there a way around this? I have looked at multiple posts before and tried various options but none seem to help, including:
Ruby on rails f.label for a check box http://ift.tt/1xz2qH5 How to add a checkbox for each row in Rails 3.2 index page?
Aucun commentaire:
Enregistrer un commentaire