I am using rails 5.x.x
, and was in the need the do the same form rails console
.
I have create rake task here-
app/lib/task_to_execute.rake
Here is the command worked for me-
Load Rails.application.load_tasks
Rake::Task['task_to_execute:task_name'].invoke
Worked for me!