I want to include
validates_confirmation_of :password
in a module but i keep getting errors like:
"undefined method `validates_confirmation_of' for Password::ClassMethods:Module"
Not sure how I can make it work.
thanks
I want to include
validates_confirmation_of :password
in a module but i keep getting errors like:
"undefined method `validates_confirmation_of' for Password::ClassMethods:Module"
Not sure how I can make it work.
thanks
You can't 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 validation method when the module is included in the ActiveRecord model, like so:
module Password::ClassMethods
def self.included(base)
base.send(:validates_confirmation_of, :password)
end
end