Can I do the following?
def ModelObserver < ActiveRecord
def after_save
Rake::Task[name].invoke
end
end
At the moment, this returns the following error:
Don't know how to build task 'name'
Any idea?
Can I do the following?
def ModelObserver < ActiveRecord
def after_save
Rake::Task[name].invoke
end
end
At the moment, this returns the following error:
Don't know how to build task 'name'
Any idea?
Use the system command :
def ModelObserver < ActiveRecord
def after_save
system "rake #{name}"
end
end
I suppose you have to load the Rake environment first, and the Rakefile. I would not try to invoke the fullblown command line to do that. You probably need to use "import" as can be found in the Rake API
Consider using delayed job or similar plugin to handle background execution. In observer (or controller) just notify background job daemon, that it should take care of some action, instead of running this task directly.