How to include validates_confrmation_of in a module in rails
1 answer
You cannot call validates_confirmation_of
in the module itself, because the module's code is executed when it is created. Instead, you want to call the validator method when the module is included in the ActiveRecord model, for example:
module Password::ClassMethods
def self.included(base)
base.send(:validates_confirmation_of, :password)
end
end
+3
a source to share