Search code examples
ruby-on-railsresqueresque-scheduler

Resque scheduler pass hash argument to Job


I have a job that receives a hash argument in its perform method. I want to call it periodically. I defined a CRON to schedule it on the resque_schedule.yml file. I am trying this way:

UpdateInterestHistoryJob:
  cron: "0 0 * * * America/Sao_Paulo"
  args:
    classifier: :SIAPE

However, inside the job, I get the arguments as an array:

["classifier", "SIAPE"]

How do I define it correctly? How do I define the job argument as a hash on the yml file?


Solution

  • I just tested here and a simple dash should be enough:

    UpdateInterestHistoryJob:
      cron: "* * * * * America/Sao_Paulo"
      args:
        - classifier: :SIAPE
    

    Also, should you need more arguments in your Resque job, simply place them without further dashes:

    UpdateInterestHistoryJob:
      cron: "* * * * * America/Sao_Paulo"
      args:
        - classifier: :SIAPE
          another: value