2011-05-23 24 views
1

我下面第2章在railstutorial.org問題:在railstutorial.org章遷移2

軌道教程中,我並試圖遷移使用耙按照說明書數據庫:「要入手演示應用程序,我們首先需要遷移數據庫採用耙(專欄2.1)「:

$ rake db:migrate 

這沒有工作,我收到以下錯誤:

C:\Users\USER1\rails_project\demo_app>rake db:migrate 
(in C:/Users/USER1/rails_project/demo_app) 
rake aborted! 
uninitialized constant Rake::DSL 
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2482:in `const_missing' 
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/tasklib.rb:8:in `<class:TaskLib>' 
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/tasklib.rb:6:in `<module:Rake>' 
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/tasklib.rb:3:in `<top (required)>' 
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/rdoctask.rb:20:in `require' 
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/rdoctask.rb:20:in `<top (required)>' 
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/tasks/documentation.rake:1:in `require' 
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/tasks/documentation.rake:1:in `<top (required)>' 
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/tasks.rb:15:in `load' 
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/tasks.rb:15:in `block in <top (required)>' 
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/tasks.rb:6:in `each' 
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/tasks.rb:6:in `<top (required)>' 
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:214:in `require' 
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:214:in `initialize_tasks' 
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:139:in `load_tasks' 
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing' 
C:/Users/USER1/rails_project/demo_app/Rakefile:7:in `<top (required)>' 
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2373:in `load' 
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile' 
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile' 
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling' 
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile' 
C:/Ruby192/lib/ruby/1.9.1/rake.rb:1991:in `run' 
C:/Ruby192/bin/rake:31:in `<main>' 

如何我能解決這個問題嗎?

回答

2

這是rake的新版本(剛剛發佈)的問題。你可以通過降低耙子到0.8.7來解決它。這是教程更簡單的解決方案。請參閱Rake 0.9.0 'undefined method 'task' '以及該問題的答案。

+0

謝謝!這工作。 – andrewcallahan 2011-05-24 03:34:30

1

您可加入耙0.8.7到你的Gemfile,如:

gem 'rake', '0.8.7' 

而在終端,你應該

bundle exec rake db:migrate 

運行,並且準備好跟隨,我希望這將幫你。

+0

這爲我工作! – 2012-09-06 12:32:07

0

我知道你早就解決了這個問題,但爲了防止任何人需要知道Rake .9.0打破了Rails和其他一些東西,你需要回到以前的版本或更新最新版本(11.1.2 ):

gem "rake", "11.1.2" 

在你的Gemfile中。

然後只需按照以下命令:

$ bundle update rake 

然後檢查耙:

$ bundle show rake 

而且它應該顯示耙11.1.2

在此之後就可以成功運行

$ bundle exec rake db:migrate 

(PS:希望這可以幫助別人:))