pauljungwirth.com - Illuminated Computing | Home

Example domain paragraphs

Rails has lots of methods to see what attributes have changed on your model. Some tell you the changes you haven’t yet saved; some, the changes you just saved. But the behavior and names of these attributes have changed over time .

I thought I had a handle on this until I saw saved_change_to_attribute? and wondered how it differs from attribute_previously_changed? . Turns out they are identical!

Well sort of. The spelling I’m used to, attribute_previously_changed? , comes from ActiveModel::Dirty (and is a bit older), whereas saved_change_to_attribute? is defined in ActiveRecord::AttributeMethods::Dirty . Not all ActiveModels are ActiveRecords. But in your ActiveRecord classes, they do the same thing.