Forum: Ruby on Rails Validation on password attr_accessor

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Richard M. (Guest)
on 2009-03-06 00:03
(Received via mailing list)
I am using the authentication example of Rails Recipes book (around
page 135)

I am trying to make a sign-up form for it

I have the following method

 def password=(pass)
      salt=[Array.new(6){rand(256).chr}.join].pack("m").chomp
      self.password_salt, self.password_hash = salt,
Digest::SHA256.hexdigest(pass + salt)
  end

which seems to work

I use

attr_accessor :password

So that I can have a password field on my form

But if I use validates_length_of :password, :within => 5..40

The password always fails the validation even if I enter more that 5
chars etc...

Any help would be appreciatted

Thanks

Richard
Japan
This topic is locked and can not be replied to.