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

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

What can cause "Required Package 'IndyCore' not found" when compiling a Delphi 2010 project? -