ArgumentError:使用activerecord-sqlserver-adapter升级到Rails 3.1后,参数数量错误(3个为2)

时间:2021-02-05 20:23:13

After upgrading to Rails 3.1 any ActiveRecord call has the following result:

升级到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>'

Anyone else run into this issue?

其他人遇到这个问题?

2 个解决方案

#1


5  

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.

您还需要更新到sql server适配器的主分支。它将是最终的3.1版本。适配器的3.0版本适用于3.0导轨。所以你的适配器已经过时了。

#2


11  

check your gemfile, you need the newest mysql2 gem for rails 3 to work:

检查你的gemfile,你需要最新的mysql2 gem for rails 3才能工作:

replace

更换

gem 'mysql2',  '0.2.7'

with

gem 'mysql2',  '>=0.3'

and run a "bundle install" and you should be good to go

并运行“捆绑安装”,你应该很高兴

#1


5  

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.

您还需要更新到sql server适配器的主分支。它将是最终的3.1版本。适配器的3.0版本适用于3.0导轨。所以你的适配器已经过时了。

#2


11  

check your gemfile, you need the newest mysql2 gem for rails 3 to work:

检查你的gemfile,你需要最新的mysql2 gem for rails 3才能工作:

replace

更换

gem 'mysql2',  '0.2.7'

with

gem 'mysql2',  '>=0.3'

and run a "bundle install" and you should be good to go

并运行“捆绑安装”,你应该很高兴