0

我正在帮助一个朋友修改他提供的 Rails 网站,我对 Rails 和 Ruby 的了解只有表面的知识,但足以完成他需要我做的事情。麻烦的是我在设置我的开发环境时遇到了这个错误,我无法弄清楚。

跑步:

$ rake db:migrate --trace

** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
development database is not configured
/var/lib/gems/1.8/gems/activerecord-2.3.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:62:in `establish_connection'
/var/lib/gems/1.8/gems/activerecord-2.3.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in `establish_connection'
/home/rory/projects/project_server/ruby_lib/project/lib/project/model.rb:21:in `init'
/home/rory/projects/project_server/ruby_lib/project/lib/project/model.rb:15:in `each'
/home/rory/projects/project_server/ruby_lib/project/lib/project/model.rb:15:in `init'
/home/rory/projects/project_server/ruby_lib/project/lib/project/project.rb:218:in `init' /home/rory/projects/project_server/rails/project_web/config/environments/development.rb:28:in `load_environment'
/var/lib/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:386:in `load_environment'
/var/lib/gems/1.8/gems/activesupport-2.3.14/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
/var/lib/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:379:in `load_environment'
/var/lib/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:137:in `process'
/var/lib/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:113:in `send'
/var/lib/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:113:in `run'
/home/rory/projects/project_server/rails/project_web/config/environment.rb:9
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:53:in `gem_original_require'
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:53:in `require'
/var/lib/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require'
/var/lib/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:547:in `new_constants_in'
/var/lib/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require'
/var/lib/gems/1.8/gems/rails-2.3.14/lib/tasks/misc.rake:4
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/var/lib/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19

跑步

$ rake db:create

按预期工作,在 mysql 中创建数据库。

我已经检查了 database.yml 是否正确缩进了空格而不是制表符。已安装所有必需的库。

该站点运行(因此我在我的开发环境中运行):

红宝石 1.8.7 轨道 2.3.14

数据库.yml:

development:
  adapter: mysql
  database: development
  username: developer
  password: devpass
  socket: /var/run/mysqld/mysqld.sock
4

1 回答 1

2

+1 on what Edd Morgan said in a comment.

Also, please paste your database.yml. For me it looks like the problem is trivial. The rake task is expecting that you have development db defined and it looks like you don't have it defined. So it raises "development database is not configured".

Most prolly you're missing a definition like:

development:
  adapter: mysql
  encoding: utf8
  host: 'you_host'
  username: 'username'
  password: 'password'
于 2012-08-22T11:43:45.723 回答