Sha256: 50f097996a58fc2dea33f6fbcd2ad3c5652328d3b8c336ab39a106b2209e59f4

Contents?: true

Size: 1.33 KB

Versions: 31

Compression:

Stored size: 1.33 KB

Contents

class Ability
  include CanCan::Ability

  def initialize(user)
    # Define abilities for the passed in user here. For example:
    #
    #   user ||= User.new # guest user (not logged in)
    #   if user.admin?
    #     can :manage, :all
    #   else
    #     can :read, :all
    #   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
    #
    # See the wiki for details:
    # https://github.com/ryanb/cancan/wiki/Defining-Abilities

    # IMPORTANT: Remove this snippet with more suitable one
    # TODO: Remove this snippet with more suitable one
    user.group.permissions.each do |permission|
      can permission.permission_type.to_sym, permission.model.constantize
    end

    if user and user.group_id == 1
      can :manage, :all
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
faalis-0.26.3 app/models/ability.rb
faalis-0.26.2 app/models/ability.rb
faalis-0.26.1 app/models/ability.rb
faalis-0.26.0 app/models/ability.rb
faalis-0.25.1 app/models/ability.rb
faalis-0.25.0 app/models/ability.rb
faalis-0.24.4 app/models/ability.rb
faalis-0.24.3 app/models/ability.rb
faalis-0.24.2 app/models/ability.rb
faalis-0.24.0 app/models/ability.rb
faalis-0.23.0 app/models/ability.rb
faalis-0.22.0 app/models/ability.rb
faalis-0.21.1 app/models/ability.rb
faalis-0.21.0 app/models/ability.rb
faalis-0.20.0 app/models/ability.rb
faalis-0.19.0 app/models/ability.rb
faalis-0.18.1 app/models/ability.rb
faalis-0.18.0 app/models/ability.rb
faalis-0.17.0 app/models/ability.rb
faalis-0.16.3 app/models/ability.rb