How to setup admin approval a model's edits

前端 未结 2 484
孤街浪徒
孤街浪徒 2021-02-09 21:46

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 do

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-09 21:53

    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.

提交回复
热议问题