Sha256: 4f4c53b27e4cd6f5e19b29c5d91058c16ad18a7e6d5f033306562388b3516ab1
Contents?: true
Size: 841 Bytes
Versions: 11
Compression:
Stored size: 841 Bytes
Contents
module Alchemy module Devise class Ability include CanCan::Ability def initialize(user) @user = user can :signup, Alchemy::User can :create, Alchemy::User if Alchemy::User.count == 0 if member? || author? || editor? can [:show, :update], Alchemy::User, id: user.id end if editor? || admin? can :index, :alchemy_admin_users can :read, Alchemy::User end if admin? can :manage, Alchemy::User end end private def member? @user.try(:has_role?, :member) end def author? @user.try(:has_role?, :author) end def editor? @user.try(:has_role?, :editor) end def admin? @user.try(:has_role?, :admin) end end end end
Version data entries
11 entries across 11 versions & 1 rubygems