Sha256: f4fa236a35c905b84ba90500d05887d986295b8490ef4919ab720dd32555071e

Contents?: true

Size: 1.13 KB

Versions: 112

Compression:

Stored size: 1.13 KB

Contents

class Ability
  include CanCan::Ability

  attr_reader :user

  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

    user ||= User.new

    # Admins
    if user.admin?
      can :manage, :all
    end
  end
end

Version data entries

112 entries across 112 versions & 1 rubygems

Version Path
pulitzer-0.15.31 spec/dummy/app/models/ability.rb
pulitzer-0.15.30 spec/dummy/app/models/ability.rb
pulitzer-0.15.29 spec/dummy/app/models/ability.rb
pulitzer-0.15.28 spec/dummy/app/models/ability.rb
pulitzer-0.15.27 spec/dummy/app/models/ability.rb
pulitzer-0.15.26 spec/dummy/app/models/ability.rb
pulitzer-0.15.25 spec/dummy/app/models/ability.rb
pulitzer-0.15.24 spec/dummy/app/models/ability.rb
pulitzer-0.15.23 spec/dummy/app/models/ability.rb
pulitzer-0.15.22 spec/dummy/app/models/ability.rb
pulitzer-0.15.21 spec/dummy/app/models/ability.rb
pulitzer-0.15.20 spec/dummy/app/models/ability.rb
pulitzer-0.15.19 spec/dummy/app/models/ability.rb
pulitzer-0.15.18 spec/dummy/app/models/ability.rb
pulitzer-0.15.17 spec/dummy/app/models/ability.rb
pulitzer-0.15.16 spec/dummy/app/models/ability.rb
pulitzer-0.15.15 spec/dummy/app/models/ability.rb
pulitzer-0.15.14 spec/dummy/app/models/ability.rb
pulitzer-0.15.13 spec/dummy/app/models/ability.rb
pulitzer-0.15.12 spec/dummy/app/models/ability.rb