Skip to content

Cancan and collection resource action items (buttons)

Elberet edited this page Apr 7, 2012 · 2 revisions

In order to get CanCan to work with actions that work on the collection of items in a resource (e.g. new, import, export) you need to check for CanCan abilities like so: (from #72)

ActiveAdmin.register Post do
  action_item :only => [:edit, :show] do
    if controller.current_ability.can?( :change_password, resource ) 
      link_to "Change Password", change_password_app_admin_user_path( resource )
    end
  end
end
Clone this wiki locally