ActiveRecord.find 参数 2 为 1 的错误数量
ActiveRecord.find Wrong number of arguments 2 for 1
User.find(16)
ArgumentError: wrong number of arguments (2 for 1)
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/relation/query_methods.rb:964:in `create_binds'
我只传入了 1 个参数,16
。这第二个参数来自哪里?
用户加载正常:
=> class User < ActiveRecord::Base {
:id => :integer,
:email => :string,
:encrypted_password => :string,
:reset_password_token => :string,
:reset_password_sent_at => :datetime,
:remember_created_at => :datetime,
:sign_in_count => :integer,
:current_sign_in_at => :datetime,
:last_sign_in_at => :datetime,
:current_sign_in_ip => :string,
等等
你用Squeel
吗? Squeel 尚不兼容 Rails 4.2。同时,您可以使用 Github 版本:
gem "squeel", github: "danielrhodes/squeel"
请注意,这不是官方存储库,但建议对官方存储库进行更改 (PR
)。
User.find(16)
ArgumentError: wrong number of arguments (2 for 1)
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/relation/query_methods.rb:964:in `create_binds'
我只传入了 1 个参数,16
。这第二个参数来自哪里?
用户加载正常:
=> class User < ActiveRecord::Base {
:id => :integer,
:email => :string,
:encrypted_password => :string,
:reset_password_token => :string,
:reset_password_sent_at => :datetime,
:remember_created_at => :datetime,
:sign_in_count => :integer,
:current_sign_in_at => :datetime,
:last_sign_in_at => :datetime,
:current_sign_in_ip => :string,
等等
你用Squeel
吗? Squeel 尚不兼容 Rails 4.2。同时,您可以使用 Github 版本:
gem "squeel", github: "danielrhodes/squeel"
请注意,这不是官方存储库,但建议对官方存储库进行更改 (PR
)。