I am trying to implement the Optimistic Locking for Race Condition. For that, I added an extra column lock_version in the Product: Model through migration.
Product: Model's new field:
# lock_version :integer(4) default(0), not null
Passing lock_version in Product: Model:
attr_accessible :lock_version
When I try to save! Optimistic Locking is working. Records, updated_at and lock_version are getting an update.
However, in the existing source code, we are using updated_all, which does not update the updated_at and lock_version. So optimistic locking is not working. Please suggest, how to implement optimistic for updated_all
Product.where(:id => self.id).update_all(attributes)
self.attributes = attributes
Aucun commentaire:
Enregistrer un commentaire