allow SQL conditions to be used with a block

This commit is contained in:
Ryan Bates
2011-04-21 00:46:06 -07:00
parent c6f9abb6ab
commit 63865cc7d8
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ module CanCan
@actions = [action].flatten
@subjects = [subject].flatten
@attributes = [extra_args.shift].flatten if extra_args.first.kind_of?(Symbol) || extra_args.first.kind_of?(Array) && extra_args.first.first.kind_of?(Symbol)
raise Error, "You are not able to supply a block with a hash of conditions in #{action} #{subject} ability. Use either one." if extra_args.first && !block.nil?
raise Error, "You are not able to supply a block with a hash of conditions in #{action} #{subject} ability. Use either one." if extra_args.first.kind_of?(Hash) && !block.nil?
@conditions = extra_args.first || {}
@block = block
end