Guest User

Untitled

a guest
Feb 21st, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. class Outage < ApplicationRecord
  2. has_many :children
  3.  
  4. after_update :if_length_changed
  5.  
  6. def if_length_changed
  7. o = Outage.find_by_id(self.id)
  8. if (o.children.any?(&:changed?) || o.children.collect(&:id).sort != o.children.pluck(&:id).sort)
  9. puts "\n\nlength was changed, count: #{o.children.count}\n\n"
  10. else
  11. puts "\n\nnotchanged, count: #{o.children.count}\n\n"
  12. end
  13. end
  14. end
Add Comment
Please, Sign In to add comment