hadees
hadees

Reputation: 1764

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. 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.

Upvotes: 6

Views: 1546

Answers (2)

Kris
Kris

Reputation: 19948

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.

Upvotes: 0

jesse reiss
jesse reiss

Reputation: 4579

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.

Upvotes: 1

Related Questions