创建日志和Rails3 的历史
我正在尝试在我的应用程序中创建一些有关用户的日志和历史记录。
例如,我想知道任何用户在任何一天总共有多少个帖子。还有其他一些很酷的指标。
首先,我的假设是,执行此操作的唯一方法是让 cron 作业运行一些任务,计算这些数字,并每天为每个用户将它们存储在一个新表中。
有没有更好或替代的方法来解决这个问题?
I'm trying to create some logs and history about users in my app.
For example, I'd like to know how many posts any user had total, on any given day. And some other cool metrics.
Off the bat, my assumption is that the only way to do this, is to have a cron job running some tasks, that calculates these numbers, and stores them for each user, every day, in a new table.
Is there a better or alternative way to go about this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
make_resourceful
等插件。对于帖子,您可以重写after :create
方法以发布到跟踪用户帖子数量的表。对于页面浏览量,您可以重写after :show
方法。您必须在控制器类中包含
make_resourceful
方法。例如:You could use a plug-in such as
make_resourceful
. In the case of posts, you could override theafter :create
method to post to a table that tracks the number of posts for the user. In the case of page views, you could override theafter :show
method.You must include the the
make_resourceful
methd in the controller class. For example: