diff --git a/lib/cancan/rule.rb b/lib/cancan/rule.rb index aa9e640..5008e0e 100644 --- a/lib/cancan/rule.rb +++ b/lib/cancan/rule.rb @@ -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 diff --git a/spec/cancan/ability_spec.rb b/spec/cancan/ability_spec.rb index eedc49b..daab5d9 100644 --- a/spec/cancan/ability_spec.rb +++ b/spec/cancan/ability_spec.rb @@ -188,6 +188,14 @@ describe CanCan::Ability do }.should raise_error(CanCan::Error, "You are not able to supply a block with a hash of conditions in read ranges ability. Use either one.") end + it "does not raise an error when attempting to use a block with an array of SQL conditions" do + lambda { + @ability.can :read, :ranges, ["published = ?", true] do + false + end + }.should_not raise_error(CanCan::Error) + end + # Attributes