raise an error when trying to make a rule with both hash conditions and a block - closes #269

This commit is contained in:
Ryan Bates
2011-03-08 17:20:32 -08:00
parent f9b181af05
commit 0de43c445b
2 changed files with 9 additions and 0 deletions

View File

@@ -11,6 +11,7 @@ module CanCan
# and subject respectively (such as :read, @project). The third argument is a hash
# of conditions and the last one is the block passed to the "can" call.
def initialize(base_behavior, action, subject, conditions, block)
raise Error, "You are not able to supply a block with a hash of conditions in #{action} #{subject} ability. Use either one." if conditions.kind_of?(Hash) && !block.nil?
@match_all = action.nil? && subject.nil?
@base_behavior = base_behavior
@actions = [action].flatten