Sha256: 3ba5f2aacfd458541b86cb4f89eef1c5f89ad4f2781b7915aaf8f36380388ef7

Contents?: true

Size: 569 Bytes

Versions: 12

Compression:

Stored size: 569 Bytes

Contents

class Ability
  include CanCan::Ability

  def initialize(user)
    alias_action :destroy, to: :delete

    @user = user

    if @user
      send(@user.user_role_type.code)
    else
      guest
    end
  end

  def guest
  end

  def default
    guest
  end

  def redactor
    default
  end

  def moderator
    default
    can :manage, Dashboard
    can [:read, :create], AdminComment
    can :destroy, AdminComment, user_id: @user.id
    cannot :destroy, User, id: @user.id
  end

  def admin
    can :manage, :all

    cannot :destroy, User, id: @user.id
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ab_admin-0.11.0 lib/generators/ab_admin/install/templates/models/ability.rb
ab_admin-0.10.0 lib/generators/ab_admin/install/templates/models/ability.rb
ab_admin-0.9.0 lib/generators/ab_admin/install/templates/models/ability.rb
ab_admin-0.8.3 lib/generators/ab_admin/install/templates/models/ability.rb
ab_admin-0.8.2 lib/generators/ab_admin/install/templates/models/ability.rb
ab_admin-0.8.1 lib/generators/ab_admin/install/templates/models/ability.rb
ab_admin-0.8.0 lib/generators/ab_admin/install/templates/models/ability.rb
ab_admin-0.7.0 lib/generators/ab_admin/install/templates/models/ability.rb
ab_admin-0.6.1 lib/generators/ab_admin/install/templates/models/ability.rb
ab_admin-0.6.0 lib/generators/ab_admin/install/templates/models/ability.rb
ab_admin-0.5.0 lib/generators/ab_admin/install/templates/models/ability.rb
ab_admin-0.4.0 lib/generators/ab_admin/install/templates/models/ability.rb