rubyherokurakerake-task

How can you pass in arguments to rake tasks called using Heroku Scheduler?


Rake tasks scheduled in Heroku found online are in the "rake task-name" format. Heroku passes in an :environment argument to the rake task, but there is no documentation about extra args being passed to a task listed in scheduler.rake

Heroku Scheduler Doc


Solution

  • You may try this:

    task :my_task, [:arg1, :arg2] => :environment do |t, args|
      puts "Args were: #{args}"
    end
    

    and then run manually to see the output:

    heroku run rake my_task
    

    UPDATE:

    this answer can be an old one already