I understand that a def self.abc, for example, is a class method, which
allows you to call its contents by just referencing model.abc (rather
model.new.abc). However, what is its role when located in a method
model like in the code below.
Also in the code below, you see :: located in the method. Isn’t that
for modules and namespaces? If so, why is it located in the method here.
These two things are preventing me from comprehending the below code:
def hash_new_password # First reset the salt to a new random string. You could choose a # longer string here but for a salt, 8 bytes of randomness is
# fine. Note this uses SecureRandom which will use your
# random number generator.
self.salt = ActiveSupport::SecureRandom.base64(8)
# Now calculate the hash of the password, with the salt prepended,
# store that in the database
self.hashed_password = Digest::SHA2.hexdigest(self.salt +
Thanks for any suggestions.
View this message in context:
Sent from the RubyOnRails Users mailing list archive at Nabble.com.