resolve issue 149

This commit is contained in:
Sokolov Yura 2010-09-13 20:15:38 +08:00 committed by Ryan Bates
parent 0b270f2d0f
commit f236b1b5a4

View File

@ -41,6 +41,7 @@ module CanCan
end end
def tableized_conditions(conditions = @conditions) def tableized_conditions(conditions = @conditions)
return conditions unless conditions.kind_of? Hash
conditions.inject({}) do |result_hash, (name, value)| conditions.inject({}) do |result_hash, (name, value)|
if value.kind_of? Hash if value.kind_of? Hash
name = name.to_s.tableize.to_sym name = name.to_s.tableize.to_sym
@ -63,7 +64,7 @@ module CanCan
hash = {} hash = {}
conditions.map do |name, value| conditions.map do |name, value|
hash[name] = associations_hash(value) if value.kind_of? Hash hash[name] = associations_hash(value) if value.kind_of? Hash
end end if conditions.kind_of? Hash
hash hash
end end
@ -71,7 +72,7 @@ module CanCan
attributes = {} attributes = {}
@conditions.each do |key, value| @conditions.each do |key, value|
attributes[key] = value unless [Array, Range, Hash].include? value.class attributes[key] = value unless [Array, Range, Hash].include? value.class
end end if conditions.kind_of? Hash
attributes attributes
end end