fixing error on protected sanitize_sql - closes #111

This commit is contained in:
Ryan Bates 2010-08-06 23:24:04 -07:00
parent 7a17586eb3
commit f8631dcc93
2 changed files with 23 additions and 19 deletions

View File

@ -71,7 +71,7 @@ module CanCan
end end
def sanitize_sql(conditions) def sanitize_sql(conditions)
@sanitizer.sanitize_sql(conditions) @sanitizer.send(:sanitize_sql, conditions)
end end
# Takes two hashes and does a deep merge. # Takes two hashes and does a deep merge.

View File

@ -19,9 +19,12 @@ class Ability
end end
end end
# this class helps out in testing nesting and SQL conditions # this class helps out in testing SQL conditions
class Person class Person
def self.sanitize_sql(hash_cond) class << self
protected
def sanitize_sql(hash_cond)
case hash_cond case hash_cond
when Hash when Hash
sanitize_hash(hash_cond).join(' AND ') sanitize_hash(hash_cond).join(' AND ')
@ -31,7 +34,7 @@ class Person
end end
end end
def self.sanitize_hash(hash) def sanitize_hash(hash)
hash.map do |name, value| hash.map do |name, value|
if Hash === value if Hash === value
sanitize_hash(value).map{|cond| "#{name}.#{cond}"} sanitize_hash(value).map{|cond| "#{name}.#{cond}"}
@ -40,4 +43,5 @@ class Person
end end
end.flatten end.flatten
end end
end
end end