1
I created a method in the Activerecord::Base and it uses another method to be defined in the model, I need to validate if the model method is defined before executing what I need, but it says it’s always undefined, what could it be? Ex:
Method of Activerecord::Base
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
In the model
def md5_fields
[cep, numero, complemento, cidade]
end
When the model method is set it returns the MD5, otherwise an empty string.
It worked, thank you very much!
– Daniel