How to setup admin approval a model's edits
Asked Answered
B

2

6

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. I found a gem called paper_trail that does had model versioning but doesn't support specifically what I want to do. 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.

Bluetongue answered 30/6, 2011 at 23:2 Comment(0)
G
1

One approach would be to do versioning with version approval.

Every edit creates a new version of the model object and its associations. At any one time there is only one "current" version of any model object (and it's representation in the database).

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. Some sort of pointer to your HEAD model object with a revision history and the ability to move HEAD to different revisions. Merging could also work similar to Git.

Hope that helps.

Gremlin answered 30/6, 2011 at 23:11 Comment(2)
I don't think creating other versions of the models is the way to go since you are going to be polluting the database with other versions. I'm actually thinking there has to be a way to modify paper_trail to do this. Like creating a new version but not updating current object.Bluetongue
well, you can cleanup old versions with a cron or on approval, but it is essentially the same problem. You create new versions, then delete ones you don't care about anymore.Gremlin
V
0

I'm looking at this same problem i.e approval of revisions, I can came across this, I would suspect you can do something similar with paper_trail.

Vulgarism answered 11/12, 2011 at 12:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.