ArgumentError:使用 activerecord-sqlserver-adapter 升级到 Rails 3.1 后参数数量错误(3 为 2)
升级到 Rails 3.1 后,任何 ActiveRecord 调用都会产生以下结果:
ArgumentError: wrong number of arguments (3 for 2)
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-sqlserver-adapter-3.0.3/lib/active_record/connection_adapters/sqlserver/database_statements.rb:185:in `select'
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/database_statements.rb:9:in `select_all'
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all'
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/base.rb:469:in `find_by_sql'
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/relation.rb:106:in `to_a'
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/relation/finder_methods.rb:155:in `all'
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/base.rb:440:in `all'
from (irb):1
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/commands/console.rb:44:in `start'
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/commands/console.rb:8:in `start'
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
还有其他人遇到此问题吗?
After upgrading to Rails 3.1 any ActiveRecord call has the following result:
ArgumentError: wrong number of arguments (3 for 2)
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-sqlserver-adapter-3.0.3/lib/active_record/connection_adapters/sqlserver/database_statements.rb:185:in `select'
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/database_statements.rb:9:in `select_all'
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all'
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/base.rb:469:in `find_by_sql'
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/relation.rb:106:in `to_a'
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/relation/finder_methods.rb:155:in `all'
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/base.rb:440:in `all'
from (irb):1
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/commands/console.rb:44:in `start'
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/commands/console.rb:8:in `start'
from /Users/username/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Anyone else run into this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查你的 gemfile,你需要最新的 mysql2 gem 才能让 Rails 3 工作:
替换
为
并运行“捆绑安装”,你应该可以开始了
check your gemfile, you need the newest mysql2 gem for rails 3 to work:
replace
with
and run a "bundle install" and you should be good to go
您还需要更新到 sql server 适配器的 master 分支。这将是最终的 3.1 版本。 3.0 版本的适配器适用于 3.0 导轨。所以你的适配器已经过时了。
You also need to update to the master branch of the sql server adapter. It will be the eventual 3.1 version. 3.0 versions of the adapter are for 3.0 rails. So your adapter is out of date.