jeudi 8 septembre 2016

enhancing the global environment task rails

On the application I am upgrading from Rails 3.2.22.4 to Rails 4.0.13, the following block of code for enhancing the global environment task has become a road-block by not working on the target Rails version:

Rails.application.class.rake_tasks do                                              
  Rake::Task["environment"].enhance do                                             
    ...                                                  
  end                                                                              
end 

This works fine on 3.2, but fails with Don't know how to build task 'environment' error message in 4.0.

In 3.2, Rails.application.class.rake_tasks returns a Proc object ( [#<Proc:0x007f978602a470@.../lib/rails/application.rb:301>] ) pointing to this line in the rails codebase. On 4.0, it returns an empty array.

The line referred to in the above Proc object seems to be removed in this commit.

What would the preferred way to enhance the environment rake task be in Rails 4.x?

Aucun commentaire:

Enregistrer un commentaire