ぼざクリタグ広場 https://hub.nizika.monster
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

22 lines
477 B

  1. require "rake"
  2. module RakeTaskHelper
  3. # Railsの rake task を一度だけロードする
  4. def load_rails_tasks!
  5. return if defined?(@rails_tasks_loaded) && @rails_tasks_loaded
  6. @rails_tasks_loaded = true
  7. Rake.application = Rake::Application.new
  8. Rails.application.load_tasks
  9. end
  10. def run_rake_task(full_name)
  11. load_rails_tasks!
  12. task = Rake::Task[full_name] # ここは rake[...] じゃなくて良い
  13. task.reenable
  14. task.invoke
  15. end
  16. end