0

I have a current form that inherits from model user and builds a form and a drop down for a selection of a role. I am currently trying to allow for multiple selectinos of roles

 <% @users.each do |u| %>

            <tr>
                <td><%= u.id %></td>
                <td><%= u.email %></td>
                <td><%= u.created_at %></td>
                <td><% if u.is_admin? %>Yes<% else %>No<% end %></td>
              <% if u.is_admin? %>
              <td>
                Admin
              </td>
              <td>
              </td>
              <% else %>
                <%= form_with model: User, url: user_update_roles_path(u.id), method: :put do |form| %>
                <td>
                  <%= form.select :role, Role.all.map(&:name), selected: u.role %>
                </td>
                <td>
                  <%= form.submit "Update" %>
                </td>
                <% end %>

How would I try to go about allowing the selection of multiple roles in my form to which it updates it?

sedepeeye
  • 11
  • 2
  • 2
    Please format this code it is very difficult to read and missing a few parts. – engineersmnky Mar 04 '21 at 21:59
  • 2
    i believe this is already answered here [multiple selection in f.select](https://stackoverflow.com/questions/4864513/ruby-on-rails-multiple-selection-in-f-select) hope this help. – Carlo Osores Mar 04 '21 at 22:10

0 Answers0