【发布时间】:2017-12-02 03:23:12
【问题描述】:
我想在 X 秒后运行延迟函数。 X 由对象的字段决定。
我试过了:
# after_create this function is triggered
def save_distance
update_attribute :distance, 5
end
# function gets delayed by X seconds (X = field named "timespan" of my object)
handle_asynchronously :save_distance, :run_at => Proc.new { timespan.seconds.from_now }
但它不起作用,返回:
undefined local variable or method `timespan' for #<Class:0x007f9b9d4f4c88>
怎么做?
【问题讨论】:
标签: ruby-on-rails ruby asynchronous delayed-job