如何解决 rails 插件上的 rake 任务弃用问题? [英] How to solve rake tasks deprecation on the rails plugin?

查看:25
本文介绍了如何解决 rails 插件上的 rake 任务弃用问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于在此处

Rails::Plugin 只不过是一个Rails::Engine,但因为它已加载在启动过程中为时已晚,它确实没有相同的配置权限作为一个裸 Rails::Engine.

Rails::Plugin is nothing more than a Rails::Engine, but since it's loaded too late in the boot process, it does not have the same configuration powers as a bare Rails::Engine.

Rails::Railtie 和Rails::Engine,你不应该继承自 Rails::Plugin.Rails::Plugin 是自动的通过简单地配置为引擎放置在供应商/插件中.自从这是自动完成的,你实际上不能声明一个Rails::Engine 在你的插件中,否则会导致同样的要加载两次的文件.这表示如果你想将引擎作为gem 它不能用作插件和反之亦然.

Opposite to Rails::Railtie and Rails::Engine, you are not supposed to inherit from Rails::Plugin. Rails::Plugin is automatically configured to be an engine by simply placing inside vendor/plugins. Since this is done automatically, you actually cannot declare a Rails::Engine inside your Plugin, otherwise it would cause the same files to be loaded twice. This means that if you want to ship an Engine as gem it cannot be used as plugin and vice-versa.

除了这个概念上的差异,之间的唯一区别Rails::Engine 和 Rails::Plugin 是插件会自动加载插件根目录下的文件init.rb"在启动过程中.

Besides this conceptual difference, the only difference between Rails::Engine and Rails::Plugin is that plugins automatically load the file "init.rb" at the plugin root during the boot process.

rails 插件中的 rake 任务已被弃用,建议使用 lib/tasks 代替.如何解决这个问题?我可以简单地将插件的任务移动到 lib/tasks 吗?

rake tasks in the rails plugins are deprecated and it is advised to use lib/tasks instead. How to solve this? Can I just simply move the plugin's tasks to the lib/tasks?

推荐答案

我刚刚在这里遇到了同样的问题,只是将所有 vendor/plugin/*/tasks/*.rake 文件移动到 lib/tasks(必须创建此目录,因为它不存在)

i've just had the same problem here, just moved all the vendor/plugin/*/tasks/*.rake files to lib/tasks (had to create this directory because it didn't existed)

然后 rake rails:update 运行良好

then rake rails:update ran fine

这篇关于如何解决 rails 插件上的 rake 任务弃用问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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