在rails3升级时ActiveRecord :: ConnectionNotEstablished

时间:2013-02-08 12:32:35

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

我正在尝试从rails 2.3升级到rails 3,并完成了rake rails:upgrade:check的事项清单,但是,当我尝试启动rails控制台时,我遇到以下错误,当我尝试并访问任何表:

irb(main):010:0> Game.all
ActiveRecord::ConnectionNotEstablished: ActiveRecord::ConnectionNotEstablished
    from /Users/ttt/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.0.20/lib/active_record/connection_adapters/abstract/connection_pool.rb:317:in `retrieve_connection'
    from /Users/ttt/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.0.20/lib/active_record/connection_adapters/abstract/connection_specification.rb:97:in `retrieve_connection'
    from /Users/ttt/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.0.20/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection'
    from /Users/ttt/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.0.20/lib/active_record/base.rb:602:in `quoted_table_name'
    from /Users/ttt/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.0.20/lib/active_record/relation/query_methods.rb:275:in `build_select'
    from /Users/ttt/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.0.20/lib/active_record/relation/query_methods.rb:189:in `build_arel'
    from /Users/ttt/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.0.20/lib/active_record/relation/query_methods.rb:149:in `arel'
    from /Users/ttt/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.0.20/lib/active_record/relation.rb:64:in `to_a'
    from /Users/ttt/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.0.20/lib/active_record/relation/finder_methods.rb:143:in `all'
    from /Users/ttt/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.0.20/lib/active_record/base.rb:444:in `all'
    from (irb):10
    from /Users/ttt/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.0.20/lib/rails/commands/console.rb:44:in `start'
    from /Users/ttt/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.0.20/lib/rails/commands/console.rb:8:in `start'
    from /Users/ttt/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.0.20/lib/rails/commands.rb:23:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

我正在使用mysql,升级到mysql2 gem,我的gem文件看起来像:

gem "rails", "3.0.20"
gem 'mysql2', '~> 0.2.17'

我还将database.yml更新为

development_default: &development_default
  adapter: mysql2
  encoding: utf8
  reconnect: false
  pool: 5
  socket: /tmp/mysql.sock

development:
  <<: *development_default
  database: some_database
  username: some_user
  password: some_password
  host: some.domain.com
  port: 4000

我可以切换回我的rails 2分支并运行代码,所以它肯定与我的升级代码有关。问题是什么或下一步在哪里?

0 个答案:

没有答案