Optimistic locking and update_attributes: not working?

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,


I’m having the same problem. Does anyone have any ideas? I’ve Googled,
looked at documentation and I’m coming up empty…