allow access to classes when using hash conditions since you'll generally want to narrow it down with a database query
This commit is contained in:
parent
8903feee70
commit
f46696348e
|
@ -1,6 +1,6 @@
|
|||
1.1.0 (not released)
|
||||
|
||||
* Removing "unauthorized!" method in favor of "authorize!"
|
||||
* Removing "unauthorized!" method in favor of "authorize!" in controllers
|
||||
|
||||
* Adding action, subject and default_message abilities to AccessDenied exception - see issue #40
|
||||
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
RDocs[http://rdoc.info/projects/ryanb/cancan] | Wiki[http://wiki.github.com/ryanb/cancan] | Screencast[http://railscasts.com/episodes/192-authorization-with-cancan] | Metrics[http://getcaliper.com/caliper/project?repo=git%3A%2F%2Fgithub.com%2Fryanb%2Fcancan.git]
|
||||
|
||||
This is a simple authorization solution for Ruby on Rails to restrict what a given user is allowed to access in the application. This is completely decoupled from any role based implementation allowing you to define user roles the way you want. All permissions are stored in a single location and not duplicated across the controller, view, and database.
|
||||
This is a simple authorization solution for Ruby on Rails to restrict what a given user is allowed to access. This is completely decoupled from any role based implementation allowing you to define user roles the way you want. All permissions are stored in a single location and not duplicated across the controller, view, and database.
|
||||
|
||||
This assumes you already have authentication (such as Authlogic[http://github.com/binarylogic/authlogic] or Devise[http://github.com/plataformatec/devise]). Either of these will define a +current_user+ model in the controller which CanCan requires.
|
||||
|
||||
This assumes you already have authentication (such as Authlogic[http://github.com/binarylogic/authlogic] or Devise[http://github.com/plataformatec/devise]) which provides a +current_user+ model.
|
||||
|
||||
== Installation
|
||||
|
||||
|
|
|
@ -241,7 +241,9 @@ module CanCan
|
|||
block_args += extra_args
|
||||
defined_block.call(*block_args)
|
||||
elsif defined_conditions
|
||||
if subject.class != Class
|
||||
if subject.class == Class
|
||||
true
|
||||
else
|
||||
defined_conditions.all? do |name, value|
|
||||
subject.send(name) == value
|
||||
end
|
||||
|
|
|
@ -145,7 +145,7 @@ describe CanCan::Ability do
|
|||
@ability.can :read, Array, :first => 1, :last => 3
|
||||
@ability.can?(:read, [1, 2, 3]).should be_true
|
||||
@ability.can?(:read, [1, 2, 3, 4]).should be_false
|
||||
@ability.can?(:read, Array).should be_false
|
||||
@ability.can?(:read, Array).should be_true
|
||||
end
|
||||
|
||||
it "should return conditions for a given ability" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user