Smarter pessimistic Active Record locking in rails