ruby - Regenerating an attribute value on a timed cycle in Rails -


okay, user models able 'spend' points give karma (arbitrary points) other users - each time user gives point, karma_amount decremented, might expect. i'd been planning on making user couldn't give karma user more once, thought cooler have finite stock of points replenishes, 1 point every 2 days.

i'm not quite sure how accomplish though - if ruby script on machine, sure, have tips having tried similar in rails?

my other concern if every user has ticking clock on live app that'll slow whole thing down. guess i'm asking in nutshell is: 'rails-y' way of doing this? naturally i'd rather find robust or elegant hacking away.

thanks much.

you want run every period of time (two hours in example). operation (replenish_karma) simple controller action (be sure restrict access, still), need sure call on regular basis.

a simple way simple cron on server initiate call specific route. if want inside rails application, may want take @ background task libs such delayed_job or resque.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -