0

我对 AWS 的所有东西都是全新的,并试图在 Beanstalk 上启动我的 Rails 应用程序。我正在关注最近的教程,但我无法将我的应用程序连接到 RDS。乘客屏幕出现错误:

production database is not configured (ActiveRecord::AdapterNotSpecified)

我的database.yml样子:

production:
  adapter: mysql2
  encoding: utf8
  database: <%= ENV['RDS_DB_NAME'] %>
  username: <%= ENV['RDS_USERNAME'] %>
  password: <%= ENV['RDS_PASSWORD'] %>
  host: <%= ENV['RDS_HOSTNAME'] %>
  port: <%= ENV['RDS_PORT'] %>

我确实配置并运行了一个 RDS 实例。我还通过 ssh 进入 EC2 实例,并验证我可以通过 RDS_USERNAME、RDS_HOSTNAME 等成功连接到 RDS。

考虑到也许我需要在 MySQL 中手动创建我的数据库,我使用 MySQL 客户端来执行此操作,但我仍然遇到同样的错误。

所以再次在 EC2 实例上,我手动检查了我的项目并运行bundle exec rake db:migrate --trace以更完整地了解它失败的位置:

** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
rake aborted!
production database is not configured
/usr/share/ruby/1.9/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:39:in `resolve_string_connection'
/usr/share/ruby/1.9/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
/usr/share/ruby/1.9/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:129:in `establish_connection'
/usr/share/ruby/1.9/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
/usr/share/ruby/1.9/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
/usr/share/ruby/1.9/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/usr/share/ruby/1.9/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
/usr/share/ruby/1.9/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:42:in `each'
/usr/share/ruby/1.9/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
/usr/share/ruby/1.9/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/base.rb:721:in `<top (required)>'
/usr/share/ruby/1.9/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:6:in `block (2 levels) in <top (required)>'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:227:in `call'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:227:in `block in execute'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:222:in `each'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:222:in `execute'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/usr/share/ruby/1.9/monitor.rb:211:in `mon_synchronize'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:159:in `invoke_with_call_chain'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:187:in `block in invoke_prerequisites'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:185:in `each'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:185:in `invoke_prerequisites'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:165:in `block in invoke_with_call_chain'
/usr/share/ruby/1.9/monitor.rb:211:in `mon_synchronize'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:159:in `invoke_with_call_chain'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:152:in `invoke'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:141:in `invoke_task'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:99:in `block (2 levels) in top_level'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:99:in `each'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:99:in `block in top_level'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:108:in `run_with_threads'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:93:in `top_level'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:71:in `block in run'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:158:in `standard_exception_handling'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:68:in `run'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/bin/rake:37:in `<top (required)>'
/usr/bin/rake:23:in `load'
/usr/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate => db:load_config
4

1 回答 1

2

是用户错误:链接文章中的复制/粘贴导致“空格”显然是一些 unicode 杂乱无章而不是 ASCII 32。

经验教训:用于od -c your_file.yml诊断潜在的有趣字符。

于 2012-12-09T13:48:48.487 回答