Reputation: 1765
I just added logger function in my model:
def self.encrypt(pass, salt)
logger.debug "--> user##encrypt"
Digest::SHA1.hexdigest(pass+salt)
logger.debug "user##encrypt <--"
end
What's happening now ?
Simply the method doesen't work anymore because the last value is a debug string!!
Is there anyway to make the last line trasparent and to still return the previous one, but passing by the previous line anyway ?
P.S I can't move the debug line and I don't want to use any other ways to track the application flow
Upvotes: 0
Views: 157
Reputation: 14222
def self.encrypt(pass, salt)
logger.debug "--> user##encrypt"
hex = Digest::SHA1.hexdigest(pass+salt)
logger.debug "user##encrypt <--"
hex
end
Upvotes: 0
Reputation: 42188
everything in ruby is an expression, so everything must have a return value. I would do it like this
def self.encrypt(pass, salt)
logger.debug "--> user##encrypt"
sha = Digest::SHA1.hexdigest(pass+salt)
logger.debug "user##encrypt <--"
return sha
end
Upvotes: 3