Skip to content Skip to sidebar Skip to footer

Only One User Allowed To Edit Content At A Time

For instance, if you wanted to edit client-site.com/pages/5, you would go to admin-site.com/pages/5/edit. I want to only let one admin access admin-site.com/pages/5/edit at a time.

Solution 1:

I suspect a better way to handle this would be to use optimistic locking:

http://railscasts.com/episodes/59-optimistic-locking

Solution 2:

You might want to look at an optimistic locking strategy, so let as many users as neccessary edit the page. But when the user tries to save the data check if the token has changed and reject the edit. For example:

  • User A starts to edit the item and holds the last modified timestamp as the token
  • User B started to edit the item and also holds the last modified timestamp as the token
  • User B saves their changes. The last modified timestamp has not changed, so the save is successful
  • User A saves their changes. The last modified timestamp has changed, so their save is rejected. User could be offered the opportunity to resolve the conflict (if there is one).

Oh looks like Rails has this already as @Andy Waite (+1) has mentioned.

Post a Comment for "Only One User Allowed To Edit Content At A Time"