0

I need to run a method once daily in a Rails application.

I'm thinking about using the whenever gem, but I realize I have a bit of a problem.

I need to run the method on an instance of an object. So I can't just have something like:

every 1.day do
    runner 'Object.method'
end

I'm thinking about doing something like

every 1.day do
  runner 'Object.where(status: "the_status_i_want").each { |object| object.method }'
end

But I have no clue how to test this behavior from within 'whenever.'

Any ideas?

Hugo
  • 2,186
  • 8
  • 28
  • 44

1 Answers1

0

Ryan Bates has a nice episode on integrating whenever gem into Rails

http://railscasts.com/episodes/164-cron-in-ruby-revised

(There is also a free version on that site, but it's kinda old, http://railscasts.com/episodes/164-cron-in-ruby)

Kalman
  • 8,001
  • 1
  • 27
  • 45