Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save tubbo/5005301 to your computer and use it in GitHub Desktop.

Select an option

Save tubbo/5005301 to your computer and use it in GitHub Desktop.
module Admin::PermissionsHelper
def permissions
['view', 'create tickets', 'edit tickets', 'delete tickets', 'change states']
end
end
<h2>Permissions for <%= @user.email %></h2>
<%= form_tag update_user_permissions_path, :method => :put do %>
<table id="permissions" cellspacing="0">
<thead>
<th>Project</th>
<% permissions.each do |name| %>
<th><%= name.titleize %></th>
<% end %>
</thead>
<tbody>
<% @projects.each do |project| %>
<tr class="<%= cycle("odd", "even") %>" id="project_<%= project_id %>">
<td><%= project.name %></td>
<% permissions.each do |name| %>
<td><%= check_box_tag "permissions[#{project.id}][#{name.titleize}]", @ability.can?(name.to_sym, project) %></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
<%= submit_tag "Update" %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment