I have a "User" model where I want to provide a unique page for email account validation. I'm constructing the unique argument for the validation route by generating a SHA ID based on the user's ID.
However, the database value and view-printed values do not match. I believe it has something to do with encoding, but I can't quite find the solution.
The "User" model contains the following code:
after_initialize :init
def init
unique_path = Digest::SHA1.hexdigest(self.id.to_s)
unique_path.force_encoding(Encoding::UTF_8) #didn't seem to work
self.email_verification_path = unique_path
end
The view contains:
<p>
<strong>Email verification url?</strong>
<%= @user.email_verification_path %>
</p>
Any guidance would be appreciated. Thanks in advance!