I have a field in an Order table that gets populated by other values which works fine as per example below:
company_name: A-Z Traders
company_tel: (111) 111 1111
MD5_hash_field: A-Z Traders|(011) 111 1111
This is working on the creation of the record through hidden field.
What I require is that MD5_hash_field then gets MD5 hashed before it is saved into the database.
Tried adding the following:
before_create :hash_field
def hash_field
self.md5_field = Digest::MD5.hexdigest(self.md5_field)
end
But does not seem to do anything
Edit:
It does Work to a Degree
<%= f.hidden_field :checksum, :value => '10011013800|Customer1|3299|ZAR|http://localhost|2012-01-30 18:30:00|secret' %>
Result should be: 31d1244f08a62f0551e9263c4835ba88
but getting : aae1ee590e4d4e08e7c0363cca90a22b
Solved:
This Does Work! - Fellow Developers when working on multiple Applications make sure you are restarting the correct App. LOL
Couldn’t you change the code to
And see what it gives you in the logs?