Sha256: 88373deef7622c6aee8642b4cc4b22060ddd8b3d4744520da022ed0f2c4f148c
Contents?: true
Size: 1.44 KB
Versions: 6
Compression:
Stored size: 1.44 KB
Contents
class Ability include CanCan::Ability include Adminpanel::ApplicationHelper def initialize(user) if user.nil? elsif user.rol.name == 'Admin' can :manage, :all else user.rol.permissions.each do |permission| if permission.to_read? can :read, symbol_class(permission.resource) elsif permission.to_publish? can :publish, symbol_class(permission.resource) elsif permission.to_create? can :create, symbol_class(permission.resource) elsif permission.to_update? can :update, symbol_class(permission.resource) elsif permission.to_destroy? can :destroy, symbol_class(permission.resource) elsif permission.to_manage? can :manage, symbol_class(permission.resource) end end end # The first argument to `can` is the action you are giving the user # permission to do. # If you pass :manage it will apply to every action. Other common actions # here are :read, :create, :update and :destroy. # # The second argument is the resource the user can perform the action on. # If you pass :all it will apply to every resource. Otherwise pass a Ruby # class of the resource. # # The third argument is an optional hash of conditions to further filter the # objects. # For example, here the user can only update published articles. # # can :update, Article, :published => true end end
Version data entries
6 entries across 6 versions & 1 rubygems