I created a method in ActiveRecord :: Base and it uses another method to be defined in the model, I need to validate if the model method is set before executing what I need, but it says is always undefined, what could it be? Ex:
ActiveRecord :: Base method
class ActiveRecord::Base
def to_md5
uuid = ''
return uuid unless Module.method_defined? :md5_fields
md5_fields.each do |mf|
uuid += mf if mf
end
Digest::MD5.hexdigest(uuid)
end
end
No model
def md5_fields
[cep, numero, complemento, cidade]
end
When the model method is set it returns the MD5 , otherwise an empty string.