How do I call a rake task in an controller?
I need it to a delayed job.
Rake::Task['task_name'].invoke(args)
But, I'd recommend against this; it's bad practice. It's better to either use Cron if you need that type of functionality, or you can use delayed_job with a custom job object specific to your needs. I'd personally recommend the latter as it causes less pain when moving servers. But delayed_job is not built to run rake tasks, it's meant to queue work items that you create.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With