I’m building a Rails project that has a cron-type job that I’m managing with Rufus Scheduler. I have two questions about how to set this up appropriately in Rails:
- Where’s the best place to put the job’s code?
- Where should I place the Rufus code to schedule the job? How should I kick it off?
To control the scheduler I would create a
config/initializers/task_scheduler.rb:Now for the
Something.to_docode, that sort of depends on what it does. Perhaps it is a data model and it should go in theapp/modelsdirectory, but if it is something more generic you might want to place it inlib/. If you wind up with a number of scheduled tasks you might want to create aapp/scheduled_tasksdirectory, but that might be overkill for just one file.