News for hackers. Stuff that matters.
Re:How our users exploited concurrency and how we fixed it by amikazmi on Friday January 11, 2013 @11:46AM (#5043461)
No need for a workaround, you have Optimistic Locking (via lock_version field)

It raises an exception in case you try to update stale data.

http://api.rubyonrails.org/classes/ActiveRecord/Locking/Opti...

Re:How our users exploited concurrency and how we fixed it by amichal on Friday January 11, 2013 @12:27PM (#5043743)
Or no table changes with http://api.rubyonrails.org/classes/ActiveRecord/Locking/Pess...

but in this specific case `affected_rows` works better as long as you know its reliable.

Re:How our users exploited concurrency and how we fixed it by EvilTrout on Friday January 11, 2013 @12:08PM (#5043604)
Right, but that involves changing your database and adding hidden form fields to your app in order for it to work on a multi process environment (like every production server should be.)

My solution is basically the same amount of lines, requires no such changes.

Re:How our users exploited concurrency and how we fixed it by gnaritas on Friday January 11, 2013 @07:02PM (#5045773)
Yes, but optimistic locking with a version is the general and known solution to this problem in all cases and is built into the framework already. Your solution works in just one case, not the general case.