为什么我不能得到rake db:迁移到ruby.railstutorial.org工作

时间:2011-05-22 23:57:48

标签: ruby ruby-on-rails-3

我决定完成教程。在我创建一个新应用并添加新的user:string email:string然后在app目录中执行rake db:migrate后,我得到了这个输出:

rake aborted! 
undefined method `task' for #<DemoApp::Application:0x00000100e49e08>
/usr/local/rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks'
/usr/local/rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.7/lib/rails/application.rb:139:in `load_tasks'
/usr/local/rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'
/Users/zigloo99/rails_projects/demo_app/Rakefile:7:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:495:in `raw_load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:78:in `block in load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:77:in `load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:61:in `block in run'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:59:in `run'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/bin/rake:31:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/bin/rake:19:in `load'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/bin/rake:19:in `<main>'

我正在使用RVM太ruby 1.9.2和rails 3.0.7,如教程中所示。 有什么想法吗?

2 个答案:

答案 0 :(得分:10)

这种情况正在发生,因为最新版本的Rake(0.9.0)在Rails 3.0应用程序上被打破,我们目前正在等待一个可靠的解决方案。

目前,解决此错误的方法是在应用程序load_tasks的{​​{1}}行上方添加此行:

Rakefile

答案 1 :(得分:3)

另一种解决方案是在开始新的rails项目之前在你的Gemfile中要求rake 0.8.7。

# Gemfile
gem 'rake', '0.8.7', :require => 'rake'

然后运行bundle install