Sha256: 98423cf3a4a31677d349ee564b0f2d9cef70b4ea4b6c0bf0a4022eb6dbc6d84c
Contents?: true
Size: 1.17 KB
Versions: 8
Compression:
Stored size: 1.17 KB
Contents
class Ability include CanCan::Ability def initialize(user) if !user.nil? and (user.admin? or user.manager?) can :access, :rails_admin # grant access to rails_admin can :dashboard # grant access to the dashboard if user.admin? admin_ui(user) elsif user.manager? manager_ui(user) end can :index, :all can :read, :all can :history, :all can :export, :all can :toggle, :all can :comments, :all #RailsAdminComments::Comments can :model_comments, :all #RailsAdminComments::ModelComments user.ability.to_cancancan(self) if user.respond_to?(:ability) and user.ability if defined?(RailsAdminUserAbilities) cannot :manage, RailsAdminUserAbilities::UserAbility end end end def admin_ui(user) can :manage, :all can :manage, User can :user_abilities, User Hancock.cancancan_admin_rules self end def manager_ui(user) can :read, :all can :show, :all cannot [:edit, :destroy, :new, :create], User can :edit, User, _id: user._id cannot :user_abilities, :all Hancock.cancancan_manager_rules self end end
Version data entries
8 entries across 8 versions & 1 rubygems