我已经用 Devise 2.2.4 安装了 Rails 3.2.13。我使用了默认的设计设置(config.mail_sender 除外),将视图从 erb 转换为 slim,仅此而已。现在我有一个奇怪的错误:用户可以注册,可以恢复密码,但不能登录!
日志:
Started POST "/users/sign_in" for 188.186.102.147 at 2013-07-14 17:58:42 +0400
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"eqZ9zAUWn+blmhNMTi3iqhjX9ac1N8EaXpqNMyp/fYw=", "user"=>{"email"=>"ertaquo@gmail.com", "password"=>"[FILTERED]", "remember_me"=>"1"}, "commit"=>"Войти"}
Completed 401 Unauthorized in 1ms
Processing by Devise::SessionsController#new as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"eqZ9zAUWn+blmhNMTi3iqhjX9ac1N8EaXpqNMyp/fYw=", "user"=>{"email"=>"ertaquo@gmail.com", "password"=>"[FILTERED]", "remember_me"=>"1"}, "commit"=>"Войти"}
Rendered devise/shared/_links.slim (3.8ms)
Rendered devise/sessions/new.html.slim within layouts/application (59.6ms)
Completed 200 OK in 208ms (Views: 83.6ms | ActiveRecord: 1.4ms)
配置/初始化程序/devise.rb:
Devise.setup do |config|
config.mailer_sender = "robot@nizarium.com"
require 'devise/orm/active_record'
config.case_insensitive_keys = [ :email ]
config.strip_whitespace_keys = [ :email ]
config.skip_session_storage = [:http_auth]
config.stretches = Rails.env.test? ? 1 : 10
config.reconfirmable = true
config.password_length = 8..128
config.reset_password_within = 6.hours
config.sign_out_via = :delete
end
模型:
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
attr_accessible :email, :password, :password_confirmation, :remember_me
end
用户表转储:
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`encrypted_password` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`reset_password_token` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`reset_password_sent_at` datetime DEFAULT NULL,
`remember_created_at` datetime DEFAULT NULL,
`sign_in_count` int(11) DEFAULT '0',
`current_sign_in_at` datetime DEFAULT NULL,
`last_sign_in_at` datetime DEFAULT NULL,
`current_sign_in_ip` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`last_sign_in_ip` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_users_on_email` (`email`),
UNIQUE KEY `index_users_on_reset_password_token` (`reset_password_token`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
LOCK TABLES `users` WRITE;
INSERT INTO `users` VALUES (1,'ertaquo@gmail.com','$2a$10$tLC/NVBIa3cyI0HkiaZ7O.oXKTZ/jVm/L8jDMsSQ27CzNWcefWkCm',NULL,NULL,NULL,2,'2013-07-14 15:49:29','2013-07-14 12:37:07','188.186.102.147','188.186.102.147','2013-07-14 12:37:07','2013-07-14 15:49:29');
UNLOCK TABLES;
有人可以帮忙吗?