Find file
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (38 sloc) 1.04 KB


Simple plugin for role-based permissions


Add permit_kermit to your Gemfile:

gem 'permit_kermit', :git => "git://"

Include module to your base controller (e.g. AdminController)

include PermitKermit

Optionally define route where user should be redirected in case of no permissions:

self.permission_denied_route = :admin

when permission_denied_route is not defined root_url will be used.

Use as before_filters in controller:

permit :admin, :moderator, :except => :destroy
permit :admin, :only => :destroy

or in views:

<%= link_to t('') users_path %>
<% permit :admin do %>
  <%= link_to t('.nav.users') users_path %>
<% end %>

Important note!

permit_kermit expects controller to have current_user variable which responds to role_names returing array with symbolized or stringified role names, e.g:

  def role_names
    @role_names ||=