Docs
Just what the doctor ordered –
detailed documentation to deeply understand Ruby and Rails.
Active Record Database Locking
Pessimistic and optimistic locking strategies in Rails
tl;dr: Database locks in Rails can prevent bad data. Pessimism freezes the whole record while optimistism is more flexible.