Rails 6 has a rich API that allows you to update your ActiveRecord objects in several different ways. Some methods have slightly different behavior which can sometimes result in unexpected consequences so it’s important to understand their differences.

Note: This article has been updated for Rails 6. Check out similar versions for Rails 3 (external link), Rails 4 (external link) and Rails 5.

Here’s a cheat sheet highlighting the differences between all the methods available for setting attributes in Rails 6:

Cheat Sheet