ActiveRecord :: Base的未定义方法`mysql_connection':Class

时间:2013-10-24 11:15:13

标签: ruby-on-rails ruby ruby-on-rails-3 activerecord gem

我已将rails2升级到rails3,当我尝试rake db:migrate时,我发现以下错误

`rake aborted!`

undefined method `mysql_connection' for ActiveRecord::Base:Class
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/activerecord-3.2.14/lib/active_record/dynamic_matchers.rb:55:in `method_missing'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/ar-octopus-0.6.1/lib/octopus/proxy.rb:153:in `select_connection'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/ar-octopus-0.6.1/lib/octopus/proxy.rb:215:in `method_missing'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/activerecord-3.2.14/lib/active_record/migration.rb:662:in `initialize'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/activerecord-3.2.14/lib/active_record/migration.rb:570:in `new'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/activerecord-3.2.14/lib/active_record/migration.rb:570:in `up'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/ar-octopus-0.6.1/lib/octopus/migration.rb:117:in `up_with_octopus'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/activerecord-3.2.14/lib/active_record/migration.rb:551:in `migrate'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/ar-octopus-0.6.1/lib/octopus/migration.rb:111:in `block in migrate_with_octopus'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/ar-octopus-0.6.1/lib/octopus/proxy.rb:171:in `run_queries_on_shard'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/ar-octopus-0.6.1/lib/octopus/proxy.rb:180:in `block in send_queries_to_multiple_shards'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/ar-octopus-0.6.1/lib/octopus/proxy.rb:179:in `each'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/ar-octopus-0.6.1/lib/octopus/proxy.rb:179:in `send_queries_to_multiple_shards'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/ar-octopus-0.6.1/lib/octopus/migration.rb:110:in `migrate_with_octopus'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/activerecord-3.2.14/lib/active_record/railties/databases.rake:193:in `block (2 levels) in <top (required)>'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/bin/ruby_executable_hooks:15:in `eval'
/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/bin/ruby_executable_hooks:15:in `<main>'

Tasks: TOP => db:migrate
(See full trace by running task with --trace)`

这是我的database.yml文件 发展:

adapter:mysql2

数据库:db

用户名:root

密码:

socket:/opt/lampp/var/mysql/mysql.sock

2 个答案:

答案 0 :(得分:0)

将其包含在拥有奇怪角色的文件中......

#encoding: utf-8 

希望这有帮助!

答案 1 :(得分:0)

谢谢大家 错误是解决了有宝石依赖问题 我有使用gem mysql2,activerecord-mysql2-adapter,mysql所以有冲突错误而不是它我只使用mysql2 gem将适配器mysql更改为mysql2