When overloading an ActiveRecord setter, I’ve often done this:
def name=(new_name)
@old_name = name
attributes['name'] = new_name
end
However, this doesn’t always seem to work (changes to attributes don’t seem to stick). Recently I’ve started doing this:
def name=(new_name)
@old_name = name
super
end
Which seems cleaner anyway. I can’t seem to find anyone talking about the correct convention - anyone know the right answer here?