Guest User

Untitled

a guest
Mar 13th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. # Sobreescribe el metodo event de acts_as_state_machine para poder agregarle funcionalidad de logger.
  2. module ValidationWatcher
  3. def self.included(receiver)
  4. receiver.extend ClassMethods
  5. receiver.class_eval do
  6. class << self
  7. alias_method_chain :validates_uniqueness_of, :watcher
  8. end
  9. write_inheritable_attribute :unique_fields, []
  10. class_inheritable_reader :unique_fields
  11. end
  12. end
  13. module ClassMethods
  14. def validates_uniqueness_of_with_watcher(*args)
  15. read_inheritable_attribute(:unique_fields) << args[0]
  16. validates_uniqueness_of_without_watcher(args)
  17. end
  18. end
  19. end
  20.  
  21. class ActiveRecord::Base
  22. include ValidationWatcher
  23. end
Add Comment
Please, Sign In to add comment