简体   繁体   English

无法在Nitrous.io上创建数据库

[英]Unable to create database on Nitrous.io

I have successfully created on app on nitrous.io and initialised the postgres database for that app. 我已经在nitroous.io上的应用程序上成功创建了该应用程序的postgres数据库。 I am now trying to configure the database for a second app on the same box. 我现在正在尝试在同一框中为第二个应用程序配置数据库。

When I run bundle exec rake db:create for the new app, I get the following error message 当我为新应用运行bundle exec rake db:create时,出现以下错误消息

rake aborted!
development database is not configured /home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:39:in `resolve_string_connection'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:63:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:create
(See full trace by running task with --trace)

If I run bundle exec rake db:create:all, I get the following error message: 如果我运行bundle exec rake db:create:all,则会收到以下错误消息:

rake aborted!
undefined method `[]' for nil:NilClass
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:50:in `block (4 levels) in <top (required)>'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:38:in `each_value'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:38:in `block (3 levels) in <top (required)>'
Tasks: TOP => db:create:all
(See full trace by running task with --trace
rake aborted!
undefined method `[]' for nil:NilClass
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:50:in `block (4 levels) in <top (required)>'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:38:in `each_value'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:38:in `block (3 levels) in <top (required)>'
Tasks: TOP => db:create:all
(See full trace by running task with --trace
So what is the correct method to create the database?
rake aborted!
undefined method `[]' for nil:NilClass
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:50:in `block (4 levels) in <top (required)>'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:38:in `each_value'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:38:in `block (3 levels) in <top (required)>'
Tasks: TOP => db:create:all
(See full trace by running task with --trace
那么创建数据库的正确方法是什么?

My db/database.yml file is as follows: 我的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:

Are you trying to use the same database for two different applications? 您是否要针对两个不同的应用程序使用同一数据库? The contents of the database.yml for the other application should be different from this one. 另一个应用程序的database.yml的内容应与此内容不同。

You will want to ensure you have indented each setting two spaces for your config/database.yml file. 您将要确保为config/database.yml文件的每个设置缩进了两个空格。 Try using these settings with the exact formatting: 尝试将这些设置与确切的格式一起使用:

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:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM