Make sure conditions on associations are pluralized

This commit is contained in:
Logan Raarup
2010-05-11 19:30:28 +08:00
committed by Ryan Bates
parent 06296b0a40
commit 605063b974
5 changed files with 26 additions and 6 deletions

View File

@@ -190,11 +190,11 @@ module CanCan
# If the ability is not defined then false is returned so be sure to take that into consideration.
# If the ability is defined using a block then this will raise an exception since a hash of conditions cannot be
# determined from that.
def conditions(action, subject)
def conditions(action, subject, options = {})
can_definition = matching_can_definition(action, subject)
if can_definition
raise Error, "Cannot determine ability conditions from block for #{action.inspect} #{subject.inspect}" if can_definition.block
can_definition.conditions || {}
can_definition.conditions(options) || {}
else
false
end