【发布时间】:2015-02-24 14:15:18
【问题描述】:
我将我的 database.yml 更改为在测试和开发中使用 sqlite3 数据库,在生产中使用 postgresql。我的应用程序在生产环境中运行良好,但是当我启动测试或开发环境时出现此错误:
Cannot load 'Rails.application.database_configuration':
undefined method'[]' for nil:NilClass (NoMethoError)
我的数据库.yml:
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production:
pool: 5
timeout: 5000
encoding: utf8
adapter: postgresql
host: <%= Rails.application.secrets[:database][:host]%>
database: <%= Rails.application.secrets[:database][:name]%>
username: <%= Rails.application.secrets[:database][:username]%>
password: <%= Rails.application.secrets[:database][:password]%>
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4