我正在尝试编写一个应用程序:
为实现这一目标,我有一个控制器:
class MyController < ApplicationController
# to be called every N minutes
def check
if @saved_state.nil?
@saved_state = get_from_API
return
end
@new_state = get_from_API
if @saved_state != @new_state
process
@saved_state = @new_state
end
end
def process
# some data processing here
end
def get_from_API
# getting data from external API here
end
end
MyController.new.check
。可以,还是有另一种方法可以在服务器上定期调用某个app方法?