Read more

Run code before or after an existing Rake task

Henning Koch
April 22, 2021Software engineer at makandra GmbH

Before

To run additional code before an existing Rake tasks you can add a dependency like this:

task :before_task do
  # runs before :existing_task
end

Rake::Task[:existing_task].enhance [:before_task]
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

The new dependency will be called after all existing dependencies.

After

To run additional code after an existing Rake tasks, pass a block to enhance:

Rake::Task[:existing_task].enhance do
  # runs after :existing task
end
Posted by Henning Koch to makandra dev (2021-04-22 14:22)