You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For example,
class Store < SimpleRecord::Base
has_many :visitors
end
class Visitor < SimpleRecord::Base
belongs_to :store
end
The following call,
Store.first.visitors.find(:all, :conditions => "gender = 'male'")
will generate these error:
ruby-1.9.2-p0 :010 > Store.first.visitors.find(:all,:conditions => "gender = 'M'")
NoMethodError: protected method sanitize_sql' called for ActiveRecord::Base:Class from /home/park/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/base.rb:1016:inmethod_missing'
from /home/park/.rvm/gems/ruby-1.9.2-p0/gems/simple_record-2.0.5/lib/simple_record.rb:1002:in sanitize_sql' from /home/park/.rvm/gems/ruby-1.9.2-p0/gems/simple_record-2.0.5/lib/simple_record.rb:1112:infind'
from (irb):10
from /home/park/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands/console.rb:44:in start' from /home/park/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands/console.rb:8:instart'
from /home/park/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands.rb:23:in <top (required)>' from script/rails:6:inrequire'
from script/rails:6:in `
'
The text was updated successfully, but these errors were encountered:
I'm having exactly this problem too. Not doing anything ActiveRecordy explicitly. The problem seems to stem from using a string instead of a key/value pair in the :conditions array. eg
:conditions => { :date => Date.today } works fine
:conditions => [ "date >= ?", Date.today ] gives the error protected method 'sanitize_sql' called for ActiveRecord::Base:Class
The class is an extension of SimpleRecord. I'm guessing you were using ActiveRecord's sanitisation stuff and perhaps they made the function protected in a recent version?
For example,
class Store < SimpleRecord::Base
has_many :visitors
end
class Visitor < SimpleRecord::Base
belongs_to :store
end
The following call,
Store.first.visitors.find(:all, :conditions => "gender = 'male'")
will generate these error:
ruby-1.9.2-p0 :010 > Store.first.visitors.find(:all,:conditions => "gender = 'M'")
'NoMethodError: protected method
sanitize_sql' called for ActiveRecord::Base:Class from /home/park/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/base.rb:1016:in
method_missing'from /home/park/.rvm/gems/ruby-1.9.2-p0/gems/simple_record-2.0.5/lib/simple_record.rb:1002:in
sanitize_sql' from /home/park/.rvm/gems/ruby-1.9.2-p0/gems/simple_record-2.0.5/lib/simple_record.rb:1112:in
find'from (irb):10
from /home/park/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands/console.rb:44:in
start' from /home/park/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands/console.rb:8:in
start'from /home/park/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands.rb:23:in
<top (required)>' from script/rails:6:in
require'from script/rails:6:in `
The text was updated successfully, but these errors were encountered: