审核和显示AR更改的最佳做法是什么?

时间:2021-05-01 01:51:57

I need to monitor user changes on active record level with associations. This changes should be displayed on a stream like page. Since every user has different permission on different areas of my application also the audit stream has to be limited to their permissions.

我需要通过关联监视活动记录级别的用户更改。此更改应显示在类似页面的流上。由于每个用户对我的应用程序的不同区域具有不同的权限,因此审计流必须限于其权限。

I know about Paper trail (does not work on all type of relations:( ), Vestal versions, acts_as_audit and so on, but do not know what is the best practise to use this gems as described in my case.

我知道Paper trail(不适用于所有类型的关系:(),Vestal版本,acts_as_audit等等,但不知道在我的情况下使用这个宝石的最佳做法是什么。

What is the best practise to audit AR changes including associations and display in an activity stream with different user rights ?

审核AR更改的最佳做法是什么,包括在具有不同用户权限的活动流中的关联和显示?

1 个解决方案

#1


1  

A simple way to audit AR activities is provided by Rails with Observer.

Rails with Observer提供了一种审计AR活动的简单方法。

Observer allows to add callback function on Models. You can then update an Acitivty model allowing to see what has been changed. Take note that Observer are independent of Controller. What or Whoever change your model should pass through your observer. The drawback is that it can slow down your application.

Observer允许在Models上添加回调函数。然后,您可以更新Acitivty模型,以查看已更改的内容。请注意,Observer独立于Controller。什么或谁改变你的模型应该通过你的观察员。缺点是它可能会降低您的应用程序速度。

A more efficient but also more complicated way would be to use EventMachine. See this article for an introduction about it.

更有效但也更复杂的方法是使用EventMachine。有关它的介绍,请参阅此文章。

A way between EventMachine and Observer could be to use delayed jobs with Observers. If you have to compute something when auditing, it can allow you to do it without slowing down your application like a sleeping turtle. There's some good tips here about Delayed Jobs.

EventMachine和Observer之间的方法可能是使用Observers的延迟作业。如果你必须在审计时计算某些东西,它可以让你这样做而不会像睡觉的乌龟那样减慢你的应用程序。这里有一些关于延迟工作的好建议。

#1


1  

A simple way to audit AR activities is provided by Rails with Observer.

Rails with Observer提供了一种审计AR活动的简单方法。

Observer allows to add callback function on Models. You can then update an Acitivty model allowing to see what has been changed. Take note that Observer are independent of Controller. What or Whoever change your model should pass through your observer. The drawback is that it can slow down your application.

Observer允许在Models上添加回调函数。然后,您可以更新Acitivty模型,以查看已更改的内容。请注意,Observer独立于Controller。什么或谁改变你的模型应该通过你的观察员。缺点是它可能会降低您的应用程序速度。

A more efficient but also more complicated way would be to use EventMachine. See this article for an introduction about it.

更有效但也更复杂的方法是使用EventMachine。有关它的介绍,请参阅此文章。

A way between EventMachine and Observer could be to use delayed jobs with Observers. If you have to compute something when auditing, it can allow you to do it without slowing down your application like a sleeping turtle. There's some good tips here about Delayed Jobs.

EventMachine和Observer之间的方法可能是使用Observers的延迟作业。如果你必须在审计时计算某些东西,它可以让你这样做而不会像睡觉的乌龟那样减慢你的应用程序。这里有一些关于延迟工作的好建议。