Ruby on Rails ActiveRecord Locking Optimistic Locking

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

user_one = User.find(1)
user_two = User.find(1)

user_one.name = "John"
user_one.save
# Run at the same instance 
user_two.name = "Doe"
user_two.save # Raises a ActiveRecord::StaleObjectError


Got any Ruby on Rails Question?