ActiveRecord#touch behaviour in Rails 3

In Rails 2.x, calling touch on an ActiveRecord model would update the
‘lock_version’ on the model, if it were present.

It would produce something like this in SQL:

UPDATE foo SET updated_at = ‘2010-07-23 10:44:19’, `lock_version’
= 2 WHERE ‘lock_version’ = 1

This would ensure that your optimistic locking policy will be followed
should another concurrent update occur on that row in your database.
Rails 3 no longer updates the ‘lock_version’ column through the touch
method. I preferred the Rails 2 behaviour, I was wondering if anyone
knew the reasoning behind this change?

Regards,
C.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs