Skip to content

Loading…

Optimistic locking: lock_version needed type information. #5747

Merged
merged 1 commit into from

3 participants

@nprncbl

Clarification that lock_version needs to be an integer typed column.

@carlosantoniodasilva
Ruby on Rails member

@mneisen thanks. Just a reminder that you can always push doc updates direct to lifo/docrails, it's an open project where everyone can push to, only for doc changes, and it's merged back to master from time to time.

@fxn fxn merged commit 4adaf7b into rails:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 1 addition and 1 deletion.
  1. +1 −1 guides/source/active_record_querying.textile
View
2 guides/source/active_record_querying.textile
@@ -695,7 +695,7 @@ Optimistic locking allows multiple users to access the same record for edits, an
<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>
c1 = Client.find(1)
Something went wrong with that request. Please try again.