First I’m quite new to ruby and rails…
I have a little application working with devise 1.5.4. I tried to upgrade to 2.0 but now authentication is failing in development mode (tests seem to be ok !?).
I searched the web quite extensively I think but found nothing. So I tried debugging (first time in ruby 🙂 : the only thing that occured to me is that the only devise “strategy” used is rememberable and that there is no access to the database in the log.
log:
Started POST "/users/sign_in" for 127.0.0.1 at 2012-02-17 15:47:22 +0100
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"B0YUlSTdLU5vHkSuB4n78rM4ikyiLzTR0PgZmkSVzro=", "user"=>{"email"=>"member001@labandprocess.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
Completed 401 Unauthorized in 52ms
Processing by Devise::SessionsController#new as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"B0YUlSTdLU5vHkSuB4n78rM4ikyiLzTR0PgZmkSVzro=", "user"=>{"email"=>"member001@labandprocess.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
Rendered devise/_links.erb (0.4ms)
Rendered devise/sessions/new.html.erb within layouts/application (5.7ms)
Rendered shared/_header.html.erb (4.5ms)
Rendered shared/_messages.html.erb (0.1ms)
Rendered shared/_footer.html.erb (27.2ms)
Rendered shared/_user_status.html.erb (0.1ms)
Completed 200 OK in 194ms (Views: 57.6ms | ActiveRecord: 2.1ms)
I made a diff between the 2 versions of my application, and the only thing that has changed beside the views and devise.rb (which is in both case the default one, i’m quite sure) is the migration :
After (2.0):
def change
create_table(:users) do |t|
## Database authenticatable
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, :default => 0
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
## Encryptable
# t.string :password_salt
## Confirmable
t.string :confirmation_token
t.datetime :confirmed_at
t.datetime :confirmation_sent_at
t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
t.string :unlock_token # Only if unlock strategy is :email or :both
t.datetime :locked_at
## Token authenticatable
# t.string :authentication_token
t.timestamps
end
add_index :users, :email, :unique => true
add_index :users, :reset_password_token, :unique => true
add_index :users, :confirmation_token, :unique => true
add_index :users, :unlock_token, :unique => true
# add_index :users, :authentication_token, :unique => true
end
Before (1.5) :
def change
create_table(:users) do |t|
t.confirmable
t.database_authenticatable :null => false
t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
t.recoverable
t.rememberable
t.trackable
# t.encryptable
# t.token_authenticatable
t.timestamps
end
add_index :users, :email, :unique => true
add_index :users, :reset_password_token, :unique => true
add_index :users, :confirmation_token, :unique => true
add_index :users, :unlock_token, :unique => true
#add_index :users, :authentication_token, :unique => true
end
and I seed data in dev mode with this:
User.create!(
:email => 'member001@xxx.com',
:password => 'mmmmmm'
).confirm!
thanks for your help!
Well, after several hours of comparison, I came to the conclusion that maybe the version of rails is the culprit. I was using 3.1.3 but after upgrading to 3.2.1 (with some other dependencies: i18n_routing and kaminari) it’s working…
this is certainly not the main reason since the devise documentation states that rails 3.1
is compatible with devise 2.0, but it’s working for now 🙂