Instead of trying to invoke the rake command in the controller, call the service objects that contain any logic that you are trying to execute.
class SomeController < ApplicationController def whatever SomeServiceObject.call end end
... and then, assuming you are talking about a custom rake task, call the service object as well:
namespace :example do desc 'important task' task :important_task do SomeServiceObject.call end end
If you are not familiar with service objects, these are just old ruby ββclasses that do some work. If you are trying to call some of the rake jobs by default (i.e.: db: migrate), I would highly recommend not doing this from the controller.
Jarrod Spillers Mar 01 '16 at 21:10 2016-03-01 21:10
source share