2011-09-30 45 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

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