gpt4 book ai didi

ruby-on-rails - 如何解决 rails 插件上的 rake 任务弃用问题?

转载 作者:行者123 更新时间:2023-12-03 16:06:12 26 4
gpt4 key购买 nike

因为在 here 中引入的概念,

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.

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.

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 吗?

最佳答案

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

然后 rake rails:update 运行正常

关于ruby-on-rails - 如何解决 rails 插件上的 rake 任务弃用问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2858165/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com