首先,我在 Rails 控制台中进行简单的 squeel 测试。
User.where{name == "abc"}
新建 Ruby 项目没有问题
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."name" = 'abc' => []
但是,当我将其应用于现有项目时,它会给我错误消息:
1.9.3p125 :001 > User.where{name == "abc"}
ArgumentError: wrong number of arguments (0 for 1) from /Users/xxx/.rvm/gems/ruby-1.9.3-p125/gems/parse_resource-1.7.3/lib/parse_resource/query.rb:11:in `where'
from /Users/xxx/.rvm/gems/ruby-1.9.3-p125/gems/parse_resource-1.7.3/lib/parse_resource/base.rb:243:in `where'
from (irb):1
from /Users/xxx/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.3/lib/rails/commands/console.rb:47:in `start'
from /Users/xxx/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.3/lib/rails/commands/console.rb:8:in `start'
from /Users/xxx/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.3/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
我发现的最相关的问题是Squeel issue #193。
它说 Squeel 没有加载。但是,就我而言,new-created 可以在同一台机器上实现。
无论如何,我尝试按照它的说明更改 active_record.rb,但是对于我现有的项目,问题仍然存在。
我正在使用 Ruby-1.9.3-p125、Rails v3.2.6 和 Squeel 1.0.14。