Forum: Ruby on Rails Salted hash login generator

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Bruno P. (Guest)
on 2009-02-17 20:20
Hello all.

Has anyone managed to use SaltedHashLoginGenerator with Rails 2.2.2?

I've been following the simple steps on the README file.

When I run script/generate salted_login User Localization  a
/config/environment/user_environment.rb file should be created, but

When I include the line: require 'environments/user_environment' in the
config/environment.rb file and start the server, it complains that the
user_environment.rb file is missing.

Does anyone know how to fix this?

I'm using Aptana IDE with RadRails.


Gavin (Guest)
on 2009-02-18 12:35
(Received via mailing list)
Hi - if you can't get this to work you could try building your own?

Class User

before_create :create_salt

  def create_salt
    unless self.salt
      self.salt = random_salt

  def random_salt
    nums = ("0".."9").to_a
    random = ""
    1.upto(5) { |i| newrand << numbers[rand(numbers.size - 1)]}
    return random

  def hash_password
    update_attribute :password, Digest::MD5.hexdigest("#{self.salt}#

  def password_matches? password_to_match
     password == Digest::MD5.hexdigest("#{self.salt}#

Just call hash_password after you save the user or update the password
and call password_matches? to check that the password provided is the
correct one.

Hope that helps?

On 17 Feb, 18:20, Bruno P. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.