不推荐全局访问 Rake DSL 方法 [英] Global access to Rake DSL methods is deprecated

查看:22
本文介绍了不推荐全局访问 Rake DSL 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读 Ruby on Rails 3 教程,并在命令行中输入以下内容:

I am working through the Ruby on Rails 3 tutorial book and typed the following on the command line:

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'

我不知道该怎么做或如何使用它.我不知道 Rake 的任何其他命令.

I am not sure what to do about it or how to work with it. I don't know any other command for Rake.

我该如何解决这个问题?

How can I fix this problem?

推荐答案

我在 Stack Overflow 问题中发现了这个 Ruby on Rails 和 Rake 问题:未初始化的常量 Rake::DSL.它指的是@DHH 推文.

I found this in Stack Overflow question Ruby on Rails and Rake problems: uninitialized constant Rake::DSL. It refers to a @DHH tweet.

将以下内容放入您的 Gemfile

Put the following in your Gemfile

gem "rake", "0.8.7"

你可能会看到类似

rake aborted!
You have already activated Rake 0.9.1 ...

我的目录中仍然有 Rake 0.9.1 的副本,因此我将其删除.

I still had a copy of Rake 0.9.1 in my directory so I deleted it.

您可以通过运行以下命令删除"Rake 0.9.1:

You can "delete" Rake 0.9.1 by running the following command:

gem uninstall rake -v=0.9.1

如果您安装了多个版本的 gem,系统会提示您选择一个版本.

If you have multiple versions of the gem installed, you'll be prompted to pick a version.

0.9.1 被清除后,我跑了

After 0.9.1 was cleaned out, I ran

bundle update rake

终于能够创建我的数据库文件.我使用的是 rake db:create,但它也适用于 rake db:migrate.

and was finally able to create my database files. I was using rake db:create, but it should work for rake db:migrate as well.

希望能帮到你.

这篇关于不推荐全局访问 Rake DSL 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆