ActiveRecord: Optimistic Offline Lock

Find of the day for me: Rails’ ActiveRecord supports Optimistic Offline Lock via lock_version column. i.e. this

>> duck1 = Duck.find_by_name "Daffy"
=> #<Duck:0xb75d2f64 @attributes={"name"=>"Daffy", "lock_version"=>"0", "id"=>"1"}>
>> duck2 = Duck.find_by_name "Daffy"
=> #<Duck:0xb75cd08c @attributes={"name"=>"Daffy", "lock_version"=>"0", "id"=>"1"}>
>> duck1.name = "Daffy le duck"
=> "Daffy le duck"
>> duck2.name = "Donald"
=> "Donald"
>> duck1.save
=> true
>> duck2.save
ActiveRecord::StaleObjectError: Attempted to update a stale object