开发者

Best method for logging activity (Ruby on Rails)

开发者 https://www.devze.com 2023-02-26 06:16 出处:网络
I want to log the user activity through my Rails 2.3.8 application.I don\'t care what the activity is, just the last time any given user did anything on the site, including viewing pages, commenting,

I want to log the user activity through my Rails 2.3.8 application. I don't care what the activity is, just the last time any given user did anything on the site, including viewing pages, commenting, logging in, etc.

One method that I can think of is creating at last_active DateTime attribute in the user model and constantly updating this attribute based on a user's activity (or possibly taking advantage of the updated_at column). I could put an after_filter on every action of every controller to call an update method, but this see开发者_高级运维ms hacky and excessive. There must be a better way. Would an observer work? If so - how? Is there something built-in to Rails that I'm missing here?

Thanks!


Put your after_filter on the ApplicationController. You can turn it off in other controllers with skip_after_filter as needed.

0

精彩评论

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