Guest User

Untitled

a guest
Apr 17th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. class ProjectObserver < ActiveRecord::Observer
  2. def after_find(project)
  3. @original = project.clone
  4. end
  5.  
  6. def after_update(project)
  7. changed_fields = []
  8. Project.columns.map(&:name).each do |column|
  9. unless column == "id" || column == "updated_at"
  10. unless project.attributes[column] == @original.attributes[column]
  11. project.logger.debug " *** #{column}: #{project.attributes[column]} vs #{@original.attributes[column]} ***"
  12. changed_fields.push(column)
  13. end
  14. end
  15. end
  16. ProjectMailer::deliver_modify(project, changed_fields)
  17. end
  18. end
Add Comment
Please, Sign In to add comment