Sha256: 1921c1ceac96951d2a25d0b20bbe67b6fc254484f7b565f4b4b95206800a2dcc
Contents?: true
Size: 856 Bytes
Versions: 3
Compression:
Stored size: 856 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 [:read, :update], Alchemy.user_class, id: user.id end if editor? || admin? can :index, :alchemy_admin_users can :read, Alchemy.user_class end if admin? can :manage, Alchemy.user_class 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
alchemy-devise-3.2.0 | lib/alchemy/devise/ability.rb |
alchemy-devise-2.1.0 | lib/alchemy/devise/ability.rb |
alchemy-devise-2.1.0.beta3 | lib/alchemy/devise/ability.rb |