From 194b4aa4f3feafc1e59b33eb8dc70f793c5921b5 Mon Sep 17 00:00:00 2001 From: Marcel Molina Date: Sun, 6 May 2007 05:01:31 +0000 Subject: Provide brief introduction to what optimistic locking is. Closes #8097. [fearoffish] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6682 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/CHANGELOG | 2 ++ activerecord/lib/active_record/locking/optimistic.rb | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index e774c83320..291309ce5d 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Provide brief introduction to what optimistic locking is. [fearoffish] + * Add documentation for :encoding option to mysql adapter. [marclove] * Added short-hand declaration style to migrations (inspiration from Sexy Migrations, http://errtheblog.com/post/2381) [DHH]. Example: diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb index 7b7f87341e..23e7239d5e 100644 --- a/activerecord/lib/active_record/locking/optimistic.rb +++ b/activerecord/lib/active_record/locking/optimistic.rb @@ -1,5 +1,15 @@ module ActiveRecord module Locking + # == What is Optimistic Locking + # + # Optimistic locking allows multiple users to access the same record for edits, and assumes a minimum of + # conflicts with the data. It does this by checking whether another process has made changes to a record since + # it was opened, an ActiveRecord::StaleObjectError is thrown if that has occurred and the update is ignored. + # + # Check out ActiveRecord::Locking::Pessimistic for an alternative. + # + # == Usage + # # Active Records support optimistic locking if the field lock_version is present. Each update to the # record increments the lock_version column and the locking facilities ensure that records instantiated twice # will let the last one saved raise a StaleObjectError if the first was also updated. Example: -- cgit v1.2.3