ruby on rails - Get changed attributes on after_update callback -


i'm trying make conditional after_update, have following:

  after_update |participant|     rails.logger.info "#{self.previous_changes} changed."     if self.previous_changes.include?(:current_distance)       #do stuff ...     end   end 

the logger prints empty hash: {}

how can check attribute has been changed?

i using: participant.update_attribute(:current_distance, distance) update attribute.

you want use changes not previous_changes. still in same save transaction looking in changes. previous_changes won't have information until after update completes.


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -