2 Commits
1.3.0 ... 1.3.1

Author SHA1 Message Date
Ryan Bates
cd74267364 releasing version 1.3.1 with sanitize_sql fix 2010-08-06 23:28:51 -07:00
Ryan Bates
f8631dcc93 fixing error on protected sanitize_sql - closes #111 2010-08-06 23:24:04 -07:00
4 changed files with 29 additions and 20 deletions

View File

@@ -1,3 +1,8 @@
1.3.1 (August 6, 2010)
* Fixing protected sanitize_sql error - see issue #111
1.3.0 (August 6, 2010)
* Adding :find_by option to load_resource - see issue #19

View File

@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "cancan"
s.version = "1.3.0"
s.version = "1.3.1"
s.author = "Ryan Bates"
s.email = "ryan@railscasts.com"
s.homepage = "http://github.com/ryanb/cancan"

View File

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

View File

@@ -19,25 +19,29 @@ class Ability
end
end
# this class helps out in testing nesting and SQL conditions
# this class helps out in testing SQL conditions
class Person
def self.sanitize_sql(hash_cond)
case hash_cond
when Hash
sanitize_hash(hash_cond).join(' AND ')
when Array
hash_cond.shift.gsub('?'){"#{hash_cond.shift.inspect}"}
when String then hash_cond
class << self
protected
def sanitize_sql(hash_cond)
case hash_cond
when Hash
sanitize_hash(hash_cond).join(' AND ')
when Array
hash_cond.shift.gsub('?'){"#{hash_cond.shift.inspect}"}
when String then hash_cond
end
end
def sanitize_hash(hash)
hash.map do |name, value|
if Hash === value
sanitize_hash(value).map{|cond| "#{name}.#{cond}"}
else
"#{name}=#{value}"
end
end.flatten
end
end
def self.sanitize_hash(hash)
hash.map do |name, value|
if Hash === value
sanitize_hash(value).map{|cond| "#{name}.#{cond}"}
else
"#{name}=#{value}"
end
end.flatten
end
end