<%# , url: { controller: "rolify", action: "update" }, html: { :turbo_method => :post } %> <%= form_with(model: user, url: rolify_path(user)) do |form| %> <% if user.errors.any? %>

<%= pluralize(user.errors.count, "error") %> prohibited this user from being saved:

<% end %>

Name: <%= user.name %>

Email: <%= user.email %>

<%= form.label :current_roles, style: "display: block" %> <%= user.roles.where(resource_type: nil).map { |role| role.name.capitalize }.to_sentence %>

<%= form.label :raw_roles, style: "display: block" %>
    
    <% user.roles.each do |role| %>
      <%= 
        extra_info = if role.resource_type
          " (#{role.resource_type}: #{role.resource_id})"
        else
          ""
        end
        "#{role.id} - #{role.name}, #{extra_info}"
      %>
    <% end %>
    
    
<%= form.label :user_roles, style: "display: block" %> <% Role.where(resource_type: nil).each do |role| %> <%= form.check_box :role_ids, { multiple: true, checked: user.role_ids.include?(role.id) }, role.id, nil %> <%= role.name %>
<% end %>
<%= form.submit %>
<% end %>