gpt4 book ai didi

ruby-on-rails - 无法在 Nitrous.io 上创建数据库

转载 作者:行者123 更新时间:2023-11-29 13:02:21 28 4
gpt4 key购买 nike

我已经在 nitrous.io 上成功创建了应用程序并为该应用程序初始化了 postgres 数据库。我现在正在尝试为同一个盒子上的第二个应用程序配置数据库。

当我为新应用程序运行 bundle exec rake db:create 时,我收到以下错误消息


rake aborted!<br/>
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'<br/>
/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'<br/>
/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'<br/>
/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)>'<br/>
Tasks: TOP => db:create<br/>
(See full trace by running task with --trace)

如果我运行 bundle exec rake db:create:all,我会收到以下错误消息:


rake aborted!<br/>
undefined method `[]' for nil:NilClass<br/>
/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)>'<br/>
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:38:in `each_value'<br/>
/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)>'<br/>
Tasks: TOP => db:create:all<br/>
(See full trace by running task with --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:

最佳答案

您需要确保为您的 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:

关于ruby-on-rails - 无法在 Nitrous.io 上创建数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25859556/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com