无法加载mysql2_adapter

时间:2014-10-08 05:48:40

标签: ruby-on-rails ruby-on-rails-4 mysql2

我正在尝试使用mysql2来运行测试。我正在研究rspec。运行" rspec规范"在终端上发出命令,得到以下错误。

Coverage report generated for RSpec to /home/parthiv/projects/Groupize/SourceCode/white_label/coverage. 0.0 / 0.0 LOC (100.0%) covered.
/home/parthiv/.rvm/gems/ruby-2.1.2@white_label/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `require': Could not load 'active_record/connection_adapters/mysql2_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile. (LoadError)
    from /home/parthiv/.rvm/gems/ruby-2.1.2@white_label/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `block in require'

Ruby版本 - ruby​​ 2.1.2p95

Mysql版本 - 5.6.20-1 + deb.sury.org~precision + 1(Ubuntu)

的Gemfile

gem 'mysql2'

配置/ database.yml的

development: &default
  adapter: mysql2
  database: my_database_name
  encoding: utf8
  min_messages: warning
  pool: 5
  timeout: 5000
  user_name: root
  password: root
  socket: /var/run/mysqld/mysqld.sock

test:
  <<: *default
  database: white_label_test

staging:
  <<: *default
  adapter: postgresql
  database: white_label_staging

production:
  adapter: mysql2
  encoding: utf8
  database: <%= ENV['RDS_DB_NAME'] %>
  username: <%= ENV['RDS_USERNAME'] %>
  password: <%= ENV['RDS_PASSWORD'] %>
  host: <%= ENV['RDS_HOSTNAME'] %>
  port: <%= ENV['RDS_PORT'] %>

适合你的帮助。

0 个答案:

没有答案