Welcome to Working With Rails


Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Authlogic's validate_password_field option
3 Posts
Authlogic's validate_password_field option

I'm using the Authlogic plugin (version 2.1.6) with Rails 3.0.0, RSpec 2.0.0rc and Ruby 1.9.2. The problem I have is I can't get an instance of my User model class to be cleared as valid. I give the User instance a username and password, but RSpec detects the instance is not valid. This happens when I configure the Authlogic option validate_password_field as true. When I configure the Authlogic option validate_password_field as false, then RSpec says the User instance is now valid. Can anyone spot what I am doing wrong here? I think I've set this up properly unless I am missing something about how Authlogic works with passwords.

Here is the gist: http://gist.github.com/619448

Have you tried setting up your :user as

let(:user) { User.new(:username => "ausername", :password => "astrongpassword") }

Authlogic should encrypt and provide the salts all on it's own.

Typically in my implementations iwth Authlogic, I've had to set a password_confirmation attribute as well. Authlogic has this as an attr_accessor to the User model. this allows it to validate that everything is kosher in terms of a user/admin entering the correct password for that user to log in with. With the {:password => "password", :password_confirmation => "password"} attributes set, Authlogic takes over and handles the salting and encryption.

Hope this helps!

3 Posts
Login to add your message