Rails - rake db:创建错误

时间:2011-05-22 12:28:04

标签: mysql ruby-on-rails ruby rake

我试图运行rake db:为mysql数据库创建但得到错误

$ rake db:create
rake aborted!
undefined method `task' for #<Sharebox::Application:0x0000010085a010>

我运行--trace并获取信息

/Users/lucasdobbins/.rvm/gems/ruby-1.9.2-head/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks'
/Users/lucasdobbins/.rvm/gems/ruby-1.9.2-head/gems/railties-3.0.7/lib/rails/application.rb:139:in `load_tasks'
/Users/lucasdobbins/.rvm/gems/ruby-1.9.2-head/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'
/Users/lucasdobbins/rails_projects/sharebox/Rakefile:7:in `<top (required)>'
/Users/lucasdobbins/.rvm/gems/ruby-1.9.2-head/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load'
/Users/lucasdobbins/.rvm/gems/ruby-1.9.2-head/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/lucasdobbins/.rvm/gems/ruby-1.9.2-head/gems/rake-0.9.0/lib/rake/application.rb:495:in `raw_load_rakefile'
/Users/lucasdobbins/.rvm/gems/ruby-1.9.2-head/gems/rake-0.9.0/lib/rake/application.rb:78:in `block in load_rakefile'
/Users/lucasdobbins/.rvm/gems/ruby-1.9.2-head/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/lucasdobbins/.rvm/gems/ruby-1.9.2-head/gems/rake-0.9.0/lib/rake/application.rb:77:in `load_rakefile'
/Users/lucasdobbins/.rvm/gems/ruby-1.9.2-head/gems/rake-0.9.0/lib/rake/application.rb:61:in `block in run'
/Users/lucasdobbins/.rvm/gems/ruby-1.9.2-head/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/lucasdobbins/.rvm/gems/ruby-1.9.2-head/gems/rake-0.9.0/lib/rake/application.rb:59:in `run'
/Users/lucasdobbins/.rvm/gems/ruby-1.9.2-head/gems/rake-0.9.0/bin/rake:31:in `<top (required)>'
/Users/lucasdobbins/.rvm/gems/ruby-1.9.2-head/bin/rake:19:in `load'
/Users/lucasdobbins/.rvm/gems/ruby-1.9.2-head/bin/rake:19:in `<main>'

这是我的database.yml文件

development:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: sharebox_development
  pool: 5
  username: root
  password:
  host: localhost

我重新安装了ruby,rails和mysql但仍然得到相同的错误任何帮助将不胜感激。干杯

1 个答案:

答案 0 :(得分:6)

你应该在你的GemFile中准确你的rake版本。

Rake 0.9刚刚离开但是打破了Rails。

这是dhh的推文:

Rake 0.9,released yesterday, broke Rails (and others). While we wait for a fix, you'll want gem 'rake', '0.8.7' in your Gemfile.

试试吗?

编辑:另外,如果您真的需要Rake 0.9而不是Rake 0.8.7,请参阅that post。也许这种修复对你有用。