Skip to content

Instantly share code, notes, and snippets.

@marcusmalmberg
Created November 14, 2012 16:48
Show Gist options
  • Save marcusmalmberg/4073250 to your computer and use it in GitHub Desktop.
Save marcusmalmberg/4073250 to your computer and use it in GitHub Desktop.
ActiveAdmin with CanCan
module ActiveAdminCanCan
def active_admin_collection
super.accessible_by current_ability
end
def resource
resource = super
authorize! permission, resource
resource
end
private
def permission
case action_name
when "show"
:read
when "new", "create"
:create
when "edit"
:update
else
action_name.to_sym
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment