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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
10509c4452e295ed526838dc54e5cb28?d=identicon&s=25 Eric Baker (ebaker)
on 2007-03-25 23: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
thrown

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,

Eric
4ea56c658e69eef33b6557b20c7a19ab?d=identicon&s=25 Joe Seeley (jseeley)
on 2007-08-09 18: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.