导轨审计日志
我正在使用 ruby on Rails 3。 我想实现审计日志。 我已经经历了这个,但我想知道是否有任何方法可以实现相同的无需 使用任何 gem 或插件?
提前致谢!
I am working with ruby on rails 3.
I want to implement audit log.
I have gone through this, but I was wondering if there is any way to implement the same without using any gem or plugin?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想在控制器/操作级别进行审核,这里有一个简单的方法:
通过继承,您也可以在其他控制器上进行审核:
在第二种情况下,:audit 将在 :verify_credentials 之前运行。
过滤器的详细信息请参见此处
如果您希望使用 active_records 在数据库级别进行审核,你可以使用观察者。 详细信息请参见此处。
If you want audit at the controller/action level, here is a simple way to do it:
And with inheritance, you get this accross other controllers as well:
In the second case, :audit will be run before :verify_credentials.
Filters are detailed here
If you want audit at the database level with active_records, you can use Observers. Detailed here.