samedi 27 juin 2015

checkboxs in a table created via form_for

I'm new to RoR so apologies if the answer is super simple. I'm trying to create a table that allows users to select other users that can collaborate on a wiki. The issue I'm having is that no matter which checkbox you select on the table. It only toggles the topmost option.

here is the code in question:

<%= form_for [@wiki, @wiki.collaborators.build] do |f| %>
  <table class="bordered hoverable">
    <tbody>
      <% @users.each do |user| %>
        <tr>
          <td><%= user.name %></td>
          <td class="right-align"><%= f.check_box :user_id %><%= f.label :user_id, "Give Access" %></td>
        </tr>
      <% end %>  
    </tbody>
  </table><br /><br />

the controller values in new

def new
  @wiki = Wiki.find(params[:wiki_id])
  @collaborator = Collaborator.new
  @users = (User.all - [current_user])
end

Aucun commentaire:

Enregistrer un commentaire