Elastic Beanstalk部署问题 - 未配置生产数据库

时间:2015-06-10 09:45:02

标签: ruby-on-rails amazon-web-services elastic-beanstalk rails-api

我遇到了将Rails API部署到Elastic Beanstalk的问题。我似乎无法摆脱以下错误:ActiveRecord::AdapterNotSpecified: 'production' database is not configured. Available: ["development", "test"]

请帮我解决这个问题。我在下面附上详细信息。

/config/database.yml

default: &defaults adapter: postgresql encoding: unicode min_messages: warning pool: 5 timeout: 10000 username: postgres host: localhost production: <<: *defaults adapter: postgresql encoding: unicode database: <%= ENV['RDS_DB_NAME'] %> username: <%= ENV['RDS_USERNAME'] %> password: <%= ENV['RDS_PASSWORD'] %> host: <%= ENV['RDS_HOSTNAME'] %> port: <%= ENV['RDS_PORT'] %> pool: 5

/config/environments/production.rb

config.assets.compile = false

config.assets.initialize_on_precompile = false

EB日志

[Instance: i-13bf48db] Command failed on instance. Return code: 1 Output: (TRUNCATED)...ib/rails/application.rb:389:in `block in run_tasks_blocks' /home/rof/cache/bundler/ruby/2.1.0/gems/sprockets-rails-2.3.1/lib/sprockets/rails/task.rb:64:in `block (2 levels) in define' Tasks: TOP => environment (See full trace by running task with --trace). Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/11_asset_compilation.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.

+++ RUBY_VERSION=2.1.5 +++ export GEM_ROOT=/opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0 +++ GEM_ROOT=/opt/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0 ++ (( 0 != 0 )) + cd /var/app/ondeck + su -s /bin/bash -c 'bundle exec /opt/elasticbeanstalk/support/scripts/check-for-rake-task.rb assets:precompile' webapp + '[' false == true ']' + su -s /bin/bash -c 'bundle exec rake assets:precompile' webapp rake aborted! ActiveRecord::AdapterNotSpecified: 'production' database is not configured. Available: ["development", "test"] /home/rof/cache/bundler/ruby/2.1.0/gems/activerecord-4.1.8/lib/active_record/connection_adapters/connection_specification.rb:257:in `resolve_symbol_connection'

1 个答案:

答案 0 :(得分:0)

如果它不在.gitignore中,请在您的database.yml中提供您想要执行的环境的凭据。