I have a rails model User that has name, email and hash fields.
I save data to this by doing:
@u = User.create(:name=>'test', :email=>"test@mail.com")
@u.save
How can I incorporate the before_create callback so that before saving the record the hash value gets a hash string by following code:
Digest::SHA1.hexdigest('something secret' + email)
How will my User model look like?
class Employee < ActiveRecord::Base
before_create :set_hash
def set_hash
//what goes in here?
end
end