2011-09-30 69 views
0

我是Rails和一般編程的新手(目前正在使用3.0.1和ruby 1.9.2的書中學習)。在Rails中的棄用警告

當我做了rake db:migrate命令時,我得到了下面的棄用警告。我不確定這是因爲我使用的是Rails的稍舊版本,還是因爲版本而發生這種情況。無論如何,任何人都可以告訴我,如果我現在應該做什麼?

由於我是一個新手,詳細的答案將不勝感激。乾杯

$ rake db:migrate 


WARNING: Global access to Rake DSL methods is deprecated. Please include 
    ... Rake::DSL into classes and modules which use the Rake DSL methods. 
WARNING: DSL method SampleApp::Application#task called at /Users/michaeljohnmitchell/.rvm/gems/[email protected]/gems/railties-3.0.1/lib/rails/application.rb:214:in `initialize_tasks' 

更新與Rake文件

# Add your own tasks in files placed in lib/tasks ending in .rake, 
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 

require File.expand_path('../config/application', __FILE__) 
require 'rake' 

SampleApp::Application.load_tasks 
+0

您能否顯示您的rakefile? – nathanvda

+0

我用我的rake文件更新了OP。感謝您的關注。 – Leahcim

回答

2

假設你正在使用耙0.9.x版本,你有兩個選擇:

  1. 至少升級到3.0.8軌道(修正了與Rake 0.9.x的集成,如here所述)。這可以通過將您的寶石文件更改爲gem rails, '3.0.8'(或更高版本)並運行bundle install來實現。

  2. 您可能會降級到Rake 0.8.x以解決此警告,但我強烈建議第一個選項。

+0

o.k.謝謝,我只使用rails 3.0.1跟隨本書。我會稍後升級 – Leahcim

+0

非常明確的答案。尼斯。 –