Good idea Daniel, although this method may still run into synchronisation issues - I think the best way would be to use optimistic locking and defer it until you save in the database - that way it's atomic. Then you'd throw the error to the user after you tried to save and failed.
http://api.rubyonrails.org/classes/ActiveRecord/Locking/Optimistic.html On 20/03/2007, at 1:56 PM, Daniel Sheppard wrote: > Just had my first instance of conflicting updates - I edited a page > while somebody else was editing it too without realising it - > luckily in this instance we were both trying to do the same thing, > but this could lead to data loss without warning. > > Time for some big red flashing warning lights. > > I'm going to add a hidden field to the Page editing page containing > the last updated value of the page - that will be sent back to > the server and the validation should check that the updated_at > field in the database matches - if not, a bit red error saying > something like > > "This page has been modified since you last loaded it. The last > user to edit this page was <username of culprit>. If you continue > saving this page their changes may be lost". > > There will then by a checkbox with that option saying something > like 'ignore <usernames>'s changes and save my changes anyway' > allowing you to continue with your save if that's what is > appropriate - that will set a second field that will tell the > object to > ignore that validation. I'm not 100% sure of doing this - you could > always copy/paste and just do it again, but I think this way is > probably nicer. > > Anybody have any objections to handling conflicts in this way? Or > better ideas (that DON'T involve writing making a version control > system for pages)? I'll probably check in a change tomorrow if > there isn't any. > > Dan. > > > > > > _______________________________________________ > Radiant mailing list > Post: [email protected] > Search: http://radiantcms.org/mailing-list/search/ > Site: http://lists.radiantcms.org/mailman/listinfo/radiant _______________________________________________ Radiant mailing list Post: [email protected] Search: http://radiantcms.org/mailing-list/search/ Site: http://lists.radiantcms.org/mailman/listinfo/radiant
