耙子流产了!未配置开发数据库

时间:2012-08-22 11:16:03

标签: ruby-on-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 rails 2.3.14

database.yml中:

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

1 个答案:

答案 0 :(得分:2)

+1 Edd Morgan在评论中所说的话。

另外,请粘贴您的database.yml。对我来说,看起来问题是微不足道的。 rake任务期望你定义了开发db,看起来你没有定义它。因此它引发了“未配置开发数据库”。

大多数人都缺少像:

这样的定义
development:
  adapter: mysql
  encoding: utf8
  host: 'you_host'
  username: 'username'
  password: 'password'