http://blog.genuitytech.com/2012/02/26/activeadmin-and-cancan/
https://gist.github.com/1264060
Created
November 14, 2012 16:48
-
-
Save marcusmalmberg/4073250 to your computer and use it in GitHub Desktop.
ActiveAdmin with CanCan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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