Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Sobreescribe el metodo event de acts_as_state_machine para poder agregarle funcionalidad de logger.
- module ValidationWatcher
- def self.included(receiver)
- receiver.extend ClassMethods
- receiver.class_eval do
- class << self
- alias_method_chain :validates_uniqueness_of, :watcher
- end
- write_inheritable_attribute :unique_fields, []
- class_inheritable_reader :unique_fields
- end
- end
- module ClassMethods
- def validates_uniqueness_of_with_watcher(*args)
- read_inheritable_attribute(:unique_fields) << args[0]
- validates_uniqueness_of_without_watcher(args)
- end
- end
- end
- class ActiveRecord::Base
- include ValidationWatcher
- end
Add Comment
Please, Sign In to add comment