Сначала я совсем новичок в рубине и рельсах ...
У меня есть небольшое приложение, работающее с devise 1.5.4. Я пытался обновить систему до версии 2.0, но теперь в режиме разработки происходит сбой аутентификации (тесты вроде бы нормальные!?).
Я искал в Интернете довольно много, я думаю, но ничего не нашел. Поэтому я попробовал отладку (впервые в ruby :): единственное, что мне пришло в голову, это то, что единственное использованное «стратегия» запоминается и что в журнале нет доступа к базе данных.
.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)
Я проверил разницу между двумя версиями моего приложения, и единственное, что изменилось рядом с views и devise.rb (который в обоих случаях является версией по умолчанию, я вполне уверен), это миграция:
После (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
До (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
и я заполняю данные в режиме разработки следующим образом:
User.create!(
:email => 'member001@xxx.com',
:password => 'mmmmmm'
).confirm!
спасибо за вашу помощь!