In a rails app, I have model code of the form:
def do_stuff(resource)
models = Model.where(resource: resource)
operated_at = DateTime.now
models.each
I assume that this problem is due to the lazy scope that you use: models = Model.where(resource: resource)
models is a proxy collection and will be resolved by rails at some point and might be re-evaluated without you knowing exactly.
so when you change an attribute and you don't reload
the object before checking a property it might not be up to date.