require 'rake' Rails.application.load_tasks # <-- MISSING LINE Rake::Task['my_task'].invoke
$ bin/rake task_name
rails raketaskname:task