Skip to content

Commit

Permalink
Merge pull request #5747 from mneisen/patch-1
Browse files Browse the repository at this point in the history
Optimistic locking: lock_version needed type information.
  • Loading branch information
fxn committed Apr 5, 2012
2 parents a9398a7 + 1f4f4d4 commit 4adaf7b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion guides/source/active_record_querying.textile
Expand Up @@ -695,7 +695,7 @@ Optimistic locking allows multiple users to access the same record for edits, an


<strong>Optimistic locking column</strong> <strong>Optimistic locking column</strong>


In order to use optimistic locking, the table needs to have a column called +lock_version+. Each time the record is updated, Active Record increments the +lock_version+ column. If an update request is made with a lower value in the +lock_version+ field than is currently in the +lock_version+ column in the database, the update request will fail with an +ActiveRecord::StaleObjectError+. Example: In order to use optimistic locking, the table needs to have a column called +lock_version+ of type integer. Each time the record is updated, Active Record increments the +lock_version+ column. If an update request is made with a lower value in the +lock_version+ field than is currently in the +lock_version+ column in the database, the update request will fail with an +ActiveRecord::StaleObjectError+. Example:


<ruby> <ruby>
c1 = Client.find(1) c1 = Client.find(1)
Expand Down

0 comments on commit 4adaf7b

Please sign in to comment.