Forum: Ruby on Rails Optimistic locking and update_attributes: not working?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Eric B. (Guest)
on 2007-03-26 01:16
Hi all,

I've searched the forumns, but I can't seem to find an answer to this
one. I'm having trouble getting optimistic locking (OL) to work in my
app, even though all of the pieces are there:

* table has lock_version column, with default of 0 (zero)
* lock_version column is being incremented by the first update (but the
second doesn't catch it)
* I'm trapping for ActiveRecord::StaleObjectError, but it is never

But nothing seems to work.

Note that currently, I'm still in development mode and using the
scaffolding code that relies on update_attributes, but I haven't found
any documentation that states whether OL works/does not work in
development mode or with update_attributes.

Anyone have an answer for this, and/or code they are willing to share?

Many thanks,

Joe S. (Guest)
on 2007-08-09 20:25
I'm having the same problem.  Does anyone have any ideas?  I've Googled,
looked at documentation and I'm coming up empty...
This topic is locked and can not be replied to.