开发者

How can I make my ActiveRecord objects only exist for 5 minutes in Ruby on Rails?

I've created a model called Request, which is created when one user makes a req开发者_运维技巧uest with another user. I'd like each request to only exist for 5 minutes. Is this possible?


Couple of ways to do this ... you could add a Sweeper or delayed job to clear the values from the database periodically. Give each record a created_at, clear after 5 minutes.

Alternative would be to do this check when presenting the information to the user ... similar idea, have a created_at, when you check the pending requests for the current user you ignore or delete any that are older than 5 minutes.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜