2

我已经用 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;

有人可以帮忙吗?

4

2 回答 2

8

好的,所以我已经为我的问题解决了这个问题。首先也是我的错误。几件事

<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>

当我尝试构建自己的登录表单时,我已经从布局中的会话/新视图中删除了这些行。因此,当我在安装我的应用程序时从我的 rake 任务中插入管理员和密码时,我没有得到帐户尚未确认或密码、用户名不正确的指示。

一旦我添加了这些行,感谢在这里找到的解决方案,我能够看到我使用了错误的电子邮件地址,因为我是一个该死的菜鸟。

于 2014-03-27T04:03:48.093 回答
-8

已解决:我已经用 Devise 安装了 Rails 4,没有这样的问题。

于 2013-07-16T12:37:38.303 回答