My friend asked this question I am not sure why it is on my StackOverflow profile.
1 Answer
Rails supports a technique called counter cache, where you can store the number of messages, comments or anything you want, without executing redundant commands.
There is a railscast that describes it very nicely :
http://railscasts.com/episodes/23-counter-cache-column
If you, however, need to stick to a cron based task, it would be very easy to store the count yourself in a statistics model like :
Statistic.new
Statistic.total_users = User.count
Statistic.total_comments = Comment.count
Statistic.save
1 Comment
Spyros
you can write a simple rails task to do it for you(more on it railscasts.com/episodes/66-custom-rake-tasks). It would be an entry to the Statistic model, yes. But the code to be executed would be in the Rake Task.