升级到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>'
还有人遇到这个问题吗?
检查您的gemfile,您需要rails 3的最新mysql2-gem才能工作:
更换
gem 'mysql2', '0.2.7'
带有
gem 'mysql2', '>=0.3'
并运行"捆绑安装",您应该可以使用
您还需要更新到sql server适配器的master分支。它将是最终的3.1版本。3.0版本的适配器适用于3.0导轨。所以你的适配器已经过时了。