Return empty set early if no can rules are present.
Thanks dkubb!
This commit is contained in:
parent
d6851debd4
commit
16bdb8d42e
|
@ -17,6 +17,7 @@ module CanCan
|
|||
def database_records
|
||||
scope = @model_class.all(:conditions => ["0 = 1"])
|
||||
cans, cannots = @rules.partition { |r| r.base_behavior }
|
||||
return scope if cans.empty?
|
||||
# apply unions first, then differences. this mean cannot overrides can
|
||||
cans.each { |r| scope += @model_class.all(:conditions => r.conditions) }
|
||||
cannots.each { |r| scope -= @model_class.all(:conditions => r.conditions) }
|
||||
|
|
Loading…
Reference in New Issue
Block a user