Project

General

Profile

Actions

Bug #4508

closed

Ability class for CanCan for Rails

Added by tobiaspreuss (Tobias Preuss) about 13 years ago. Updated over 11 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
Backport:
[ruby-core:<unknown>]

Description

=begin
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]

When I use the following CanCan::Ability class, Ruby dies.

class Ability

include CanCan::Ability

def initialize(user)

  alias_action :index, :show, :list, :to => :read
  alias_action :new, :create, :to => :create
  alias_action :edit, :update, :to => :update
  alias_action :delete, :to => :destroy

  #user ||= User.new # Guest user (not logged in).
  can :read, :all
  if user

    if user.is_admin?
      puts "\n\nCurrent user #{user.email} is an admin.\n"
      can :manage, :all
    else
      puts "\n\nCurrent user #{user.email} is NO admin.\n"

      # Study.
      can [:create, :new], [Study, Facility, Subject]
      can [:update, :destroy, :delete], [Study], :student => user
    end
  end
end

end
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0