I'm upgrading a Rails 3 application to Rails 4 and had existing plugins using the old vendor/plugins directory. Where possible I have switched to gems, in other cases I have moved these to lib and created initializers in config/initializers.
Some of these plugins add rake tasks that now are failing with the error "Don't know how to build task 'X' where X
is any task that was migrated to the lib directory. Is there some other steps that need to be taken to migrate rake tasks when upgrading to Rails 4?
The old Rails vendor plugin style would put rake tasks into a lib/tasks sub-folder under the plugins sub-directory. The old file structure looked something like this.
/vendor/plugins/plugin1/lib/tasks/foo.rake
/vendor/plugins/plugin2/lib/tasks/bar.rake
Rails 4 did away with support for plugins so you needed to switch to gems or move the plugins to the lib sub-directory and create an initializer. This gives a new directory structure for the rake tasks that looks something like this.
/lib/plugin1/lib/tasks/foo.rake
/lib/plugin2/lib/tasks/bar.rake
To pick up these rake tasks, but keep the structure so that it stays packaged with the plugin you can add the following line to Rakefile.
Dir["lib/**/lib/tasks/**/*.rake"].each{ |r| load r }