I have a few files in a project that require post-processing each time they are updated.
I can extract these processes into a rake task. My question is:
How can a rake task be run automatically every time a specific file is saved?
I have a few files in a project that require post-processing each time they are updated.
I can extract these processes into a rake task. My question is:
How can a rake task be run automatically every time a specific file is saved?
I think you will be able to do this using invoke method
if @file.save
.
.
.
Rake::Task['task_name'].invoke
end
see this SO question for more info
You can do this in your model file.
after_save :update_rake_operations
def update_rake_operations
task = "update_status"
Rake::Task[task].invoke
end
You should have the below code in Rakefile under project folder. This should be present by default.
require File.expand_path('../config/application', __FILE__)
require 'rake'
ProjectFolder::Application.load_tasks