after_commit for an attribute

Old question, but this is one method that I’ve found that might work with the after_commit callback (working off paukul’s answer). At least, the values both persist post-commit in IRB.

after_commit :callback, 
  if: proc { |record| 
    record.previous_changes.key?(:attribute) &&
      record.previous_changes[:attribute].first != record.previous_changes[:attribute].last
  }

Leave a Comment