开发者

How to solve rake tasks deprecation on the rails plugin?

开发者 https://www.devze.com 2022-12-30 12:28 出处:网络
Because of the concept introduced in here, Rails::Plugin is nothing more than a Rails::Engine, but since it\'s loaded

Because of the concept introduced in 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 开发者_C百科during the boot process.

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?


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)

then rake rails:update ran fine


If you're the developer of a plugin, you would simply move

my_cool_plugin/tasks

to

my_cool_plugin/lib/tasks
0

精彩评论

暂无评论...
验证码 换一张
取 消