I have an after_save callback for the model, and I call previous_changes to see if the attribute (is_complete) has changed. Even when the attribute changes, previous_changes returns an empty hash.
Here's the callback:
after_save do |record|
puts "********************"
puts record.previous_changes.to_s
puts record.is_complete
puts "********************"
end
and here is what I get in the log:
********************
{}
true
********************
********************
{}
false
********************
If the value of is_complete is changed from true to false, it must be in the hash of previous_changes. Updating is done using normal save! and I do not reload the object.
--- UPDATE ---
I did not consider this when I asked the question, but my model uses the awesome_nested_set gem, and it seems like it is reloading the object or somehow interfering with the after_save callback. When I comment on act_as_nested_set, the callback works fine.
--- 2 ---
round_save, , , , , , . :
around_save do |record, block|
is_complete_changed = true if record.is_complete_changed?
block.call
if is_complete_changed
** do stuff **
end
end