[英]How to setup admin approval a model's edits
I need a system where a regular user can edit a model but the edits don't actually happen until they are approved by an administrator.我需要一个普通用户可以编辑 model 的系统,但在得到管理员批准之前,这些编辑实际上不会发生。 I found a gem called paper_trail that does had model versioning but doesn't support specifically what I want to do.
我发现了一个名为paper_trail的 gem,它确实有 model 版本控制,但不具体支持我想做的事情。 I'm wondering how other people have handled this problem.
我想知道其他人是如何处理这个问题的。 I should add that there are also associations that I would like to be able for the user to edit at the same time.
我应该补充一点,我还希望用户能够同时编辑一些关联。 They aren't very complicated, for example one is aliases.
它们不是很复杂,例如一个是别名。
The more complicated part maybe be the case where multiple users edit the same model and trying to do some sort of merge.更复杂的部分可能是多个用户编辑相同的 model 并尝试进行某种合并的情况。
One approach would be to do versioning with version approval.一种方法是在版本批准的情况下进行版本控制。
Every edit creates a new version of the model object and its associations.每次编辑都会创建一个新版本的 model object 及其关联。 At any one time there is only one "current" version of any model object (and it's representation in the database).
在任何时候,任何 model object (以及它在数据库中的表示)都只有一个“当前”版本。
If two users submit two separate edits, these would create two "pending" versions.如果两个用户提交两个单独的编辑,这将创建两个“待定”版本。
An admin would approve edits by moving the current version to the new "pending" version.管理员将通过将当前版本移动到新的“待定”版本来批准编辑。 Merges could be accomplished as well, but that could be very domain specific, and could result in conflicts, so keeping separate versions would be smart anyways.
合并也可以完成,但这可能是非常特定于域的,并且可能导致冲突,因此保持单独的版本无论如何都是明智的。
There are a few ways to accomplish this, and the best would depend on the dynamics of the situation.有几种方法可以实现这一点,最好的方法取决于情况的动态。
I'd recommend looking at how Git works and trying to model your system after that.我建议您查看 Git 的工作原理,然后尝试 model 您的系统。 Some sort of pointer to your HEAD model object with a revision history and the ability to move HEAD to different revisions.
某种指向您的 HEAD model object 的指针,具有修订历史记录和将 HEAD 移动到不同修订的能力。 Merging could also work similar to Git.
合并也可以类似于 Git。
Hope that helps.希望有帮助。
I'm looking at this same problem ie approval of revisions, I can came across this , I would suspect you can do something similar with paper_trail .我正在研究同样的问题,即批准修订,我可以遇到这个问题,我怀疑你可以用paper_trail做类似的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.