我正在阅读Ruby on Rails 3教程,并在命令行中输入了以下内容:
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 DemoApp::Application#task called at /Users/imac/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks'
我不知道该怎么做,也不知道如何使用它。我不知道瑞克还有什么其他命令。
我如何解决这个问题?
发布于 2011-06-11 08:05:02
对我来说,在调用应用程序load_tasks之前将include Rake::DSL
添加到Rakefile也是可行的。
因此,在上面的用户案例中,在Rakefile中的DemoApp::Application.load_tasks
之前。
发布于 2011-06-30 23:29:06
我在Windows上的安装程序也遇到了同样的问题。Ruby 1.9.2和Rails 3.0.9。下面是我所做的:
bundle update rake
bundle show rake
这样做之后,我运行的是rake0.9.2。
然后我更新了应用程序根文件夹中的Rakefile,如下所示:
require File.expand_path('../config/application', __FILE__)
require 'rake'
# If you named your application something other than SampleApp, change that below
module ::SampleApp
class Application
include Rake::DSL
end
end
module ::RakeFileUtils
extend Rake::FileUtilsExt
end
SampleApp::Application.load_tasks
正如评论中所指出的,确保您的应用程序的名称在上面的两个适当的行中是正确的。
发布于 2011-09-17 20:10:19
如果您在更高版本的Rails (如3.+)上看到了这一点,那么您可能还想通过使用ruby并为您的项目创建一个特定的http://beginrescueend.com/ & gemset来验证您的环境是否干净。
在每个项目的基础上使用.rvmrc文件,这将确保您不会将较旧的系统gems添加到项目中。它以前也咬过我。
这就避免了不得不摆弄生成的Rakefile之类的东西。
https://stackoverflow.com/questions/6199301
复制相似问题