0

I'm sure I've got the completely wrong of the stick with regard to how Clockwork works. Basically I'm got a number of methods that exist within a Controller, as they're currently triggered by navigating to their relevant routes. I'm trying to get clockwork to run these methods, but I get a number of errors, including No Method Errors.

I've had a look around but can't seem to find anything to point me in the right direction. If this isn't the way to do it, where do I need to put my action logic in order to execute it using Clockwork?

This is my clock.rb file at the moment, which results in a NoMethodError

require 'clockwork'
require './config/boot'
require './config/environment'

include Clockwork

handler do |job|
  puts "Running #{job}"
end

every(3.minutes, 'application.tester') { ApplicationController::tester }
4

1 回答 1

0

这是可怕的 OO 实践,让 Rails 调用控制器方法。无论您在这些控制器方法中拥有什么代码,都将移至其自己的类或模块,并在 Rake 任务中调用它们。然后继续在 Clockwork 中调用该 rake 任务。

于 2013-08-29T12:34:29.273 回答