问题描述
什么是最好的/清洁/容易维护的记录编辑历史Rails的方式?
What is the best/cleanest/easiest way to maintain the edit history of records in Rails?
我要找的记录 - 谁做的修改以及何时回滚到早期版本的记录的能力。
I'm looking for logging - who made the edits and when and the ability to rollback to earlier versions of records.
我的猜测是,你会使用在更新或删除ActiveRecord的回调和,而不是更新/删除记录,你将创造一个新的,具有某种标识,以保持相同的记录有关,也许是场区分哪些记录是最新的,以及版本字段
My guess is that you would use ActiveRecord callbacks on updates or deletes and instead of updating/deleting records you would create a new one and have some sort of identifier to keep the same "record" associated, maybe a field to distinguish which record is current, and a version field.
我依稀记得看到一些插件,但我似乎无法找到他们在moment.r
I vaguely recall seeing some plugins but I can't seem to find them at the moment.r
(是否有一个术语,这一点,我不知道吗?)
(Is there a term for this that I don't know?)
推荐答案
acts_as_audited胜手了。你甚至可以用acts_as_versioned它。该插件,网页说明了一切。经过下面的页面上的帖子的讨论意见。开发者已经发布的问题,并已获得来自作者和其他人的积极响应。
acts_as_audited wins hands down. You can even use acts_as_versioned with it. The plugin-page explains everything. Go through the discussion comments below the post on the page. Developers have posted issues and have obtained positive responses from the author and others.
我已经使用这个插件在很多的应用程序,我觉得非常非常有用的。强烈推荐。
I have used this plugin in many apps and I find it very very useful. Highly recommended.
下面是从插件页面中的preVIEW:
Here is a preview from the plug-in page:
acts_as_audited是一个活动记录 插件,记录所有修改 你的模型在审核表中。它 使用多态关联 存储一个审计记录为任何的 你希望有模型对象 审计。审计日志存储 模型的变化已开启,则 行动(创建,更新,销毁),一 的变化serialzied散列,并 可选的执行用户 采取行动。
这篇关于什么是保持创纪录的编辑历史与Rails和ActiveRecord的最好的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!