未定义的方法`connect'对于类`ActiveRecord :: ConnectionAdapters :: MysqlAdapter'

时间:2014-10-26 10:20:45

标签: ruby-on-rails ruby ruby-on-rails-3.2

我正在将我的应用程序从rails 2.3升级到rails 3.2.19并使用ruby 2.1.2。我正在进行升级,但是当我尝试启动无法解决的服务器时出现错误。以前应用程序使用的是mysql gem,现在我使用的是mysql2 gem。我已经更改了database.yml文件并将其转换为mysql2但仍然给出了以下错误:

  

/home/dan/.rvm/gems/ruby-2.1.2@upgrade/gems/activesupport-3.2.19/lib/active_support/core_ext/module/aliasing.rb:31:in alias_method': undefined method connect& #39;对于课程ActiveRecord::ConnectionAdapters::MysqlAdapter' (NameError) from /home/dan/.rvm/gems/ruby-2.1.2@upgrade/gems/activesupport-3.2.19/lib/active_support/core_ext/module/aliasing.rb:31:in alias_method_chain'

这是我database.yml文件中的内容:

  development:
  adapter: mysql2
  encoding: utf8
  database: dev_database
  username: root
  password:
  pool: 5
  socket: /opt/lampp/var/mysql/mysql.sock

1 个答案:

答案 0 :(得分:0)

您是否在database.yml中定义了“host”,如: -

development:
    adapter: mysql2
    encoding: utf8
    database: dev_database
    username: root
    password:
    host :localhost(0r 127.0.0.1)
    pool: 5
    socket: /opt/lampp/var/mysql/mysql.sock