开发者

How to trigger a model action based on a preset time in Rails

I have a pending transaction between two Accounts, and after a preset date, if nothing happens, t开发者_运维问答hen the transaction should be automatically expired. (I need this expiration to happen in real time, and not when one of the users login to their account).

What would be the best way to create a timer to check against transactions and set their status in near time?

Thank you.


Use a rake task triggered with a cron job, as Abe Petrillo suggests. There is overhead as rake must load up the rails env each time, but if this happens based on date then i guess you just need to run it once a day, in which case the overhead isn't significant.

That cron-in-ruby thing looks kind of overengineered to me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜