Ruby on rails 无法在Nitrous.io上创建数据库
我已经在nitrous.io上成功创建了on应用程序,并为该应用程序初始化了postgres数据库。我现在正试图在同一个框中为第二个应用程序配置数据库 当我为新应用程序运行bundle exec rake db:create时,我收到以下错误消息Ruby on rails 无法在Nitrous.io上创建数据库,ruby-on-rails,postgresql,nitrousio,Ruby On Rails,Postgresql,Nitrousio,我已经在nitrous.io上成功创建了on应用程序,并为该应用程序初始化了postgres数据库。我现在正试图在同一个框中为第二个应用程序配置数据库 当我为新应用程序运行bundle exec rake db:create时,我收到以下错误消息 雷克流产了 未配置开发数据库 /home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active\u record/connection\u adapters/abst
雷克流产了
未配置开发数据库
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active\u record/connection\u adapters/abstract/connection\u specification.rb:39:在“解析字符串\u连接”中
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active\u record/connection\u adapters/abstract/connection\u specification.rb:25:in'spec'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active\u record/connection\u adapters/abstract/connection\u specification.rb:130:在“建立连接”中
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active\u record/railties/databases.rake:63:in'block(2层)in'
任务:TOP=>db:create
(通过使用--trace运行任务查看完整跟踪)
如果运行bundle exec rake db:create:all,则会收到以下错误消息:
雷克流产了
nil的未定义方法“[]”:NilClass
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active\u record/railties/databases.rake:50:in'block(4层)in'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active\u record/railties/databases.rake:38:in'each\u value'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active\u record/railties/databases.rake:38:in'block(3层)in'
任务:TOP=>db:create:all
(通过使用--trace运行任务,请参阅完整跟踪。)
那么,创建数据库的正确方法是什么
我的db/database.yml文件如下:
# database configuration for Nitrous.io
development:
adapter: postgresql
encoding: unicode
database: better_life-dev
pool: 5
host: localhost
username: action
password:
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.
#host: localhost
# The TCP port the server listens on. Defaults to 5432.
# If your server runs on a different port number, change accordingly.
#port: 5432
# Schema search path. The server defaults to $user,public
#schema_search_path: myapp,sharedapp,public
# Minimum log levels, in increasing order:
# debug5, debug4, debug3, debug2, debug1,
# log, notice, warning, error, fatal, and panic
# Defaults to warning.
#min_messages: notice
# 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:
adapter: postgresql
database: better_life-test
pool: 5
host: localhost
username: action
password:
production:
adapter: postgresql
encoding: unicode
database: better_life-prod
pool: 5
host: localhost
username: action
password:
您是否尝试将同一数据库用于两个不同的应用程序?
其他应用程序的
database.yml
的内容应与此应用程序不同。您需要确保为config/database.yml
文件将每个设置缩进两个空格。请尝试使用这些设置和精确的格式:
development:
adapter: postgresql
encoding: unicode
database: better_life-dev
pool: 5
host: localhost
username: action
password:
test:
adapter: postgresql
database: better_life-test
pool: 5
host: localhost
username: action
password:
production:
adapter: postgresql
encoding: unicode
database: better_life-prod
pool: 5
host: localhost
username: action
password:
我对此投了更高的票,因为它值得在两个应用程序中检查相同的数据库。在我的情况下,gman给出了答案。谢谢你的礼貌。