Invoke rake task from Rails console

If you want to automate the process of invoking rake tasks from code or just simply invoke it from the console, you can load rake and its tasks and then call the invoke method:

require 'rake'

Rails.application.load_tasks
Rake::Task['db:seed'].invoke
#8
, 12-07-2021