我在恢复新密码时遇到问题。我已经设置了邮件程序,并且可以正常接收密码说明。当我单击电子邮件中的重置密码链接时,我可以正常进入更改新密码页面。但是,当我输入新密码时,我得到一个“请检查以下问题”,没有错误,并且密码没有更改。
当我检查日志时,我看到:
2013-10-08T17:10:35.118663+00:00 app[web.1]: Started PUT "/users/password" for 24.87.52.189 at 2013-10-08 17:10:35 +0000
2013-10-08T17:10:35.354246+00:00 app[web.1]: Processing by Devise::PasswordsController#update as HTML
2013-10-08T17:10:35.354246+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"7LQ4VtOfwDZTV2tw4YwPoj8sqD6UGeCd5NvQkdANrH0=", "user"=>{"reset_password_token"=>" [FILTERED]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Change my password"}
2013-10-08T17:10:35.354246+00:00 app[web.1]: Rendered devise/shared/_links.erb (0.4ms)
2013-10-08T17:10:35.354246+00:00 app[web.1]: Rendered devise/passwords/edit.html.erb within layouts/application (5.2ms)
2013-10-08T17:10:35.354246+00:00 app[web.1]: Rendered layouts/_shim.html.erb (0.0ms)
2013-10-08T17:10:35.354246+00:00 app[web.1]: Rendered layouts/_footer.html.erb (0.6ms)
2013-10-08T17:10:35.354246+00:00 app[web.1]: Completed 200 OK in 232ms (Views: 8.9ms | ActiveRecord: 0.0ms)
2013-10-08T17:10:35.741022+00:00 heroku[router]: at=info method=GET path=/users/password host=skalefree.net fwd="24.87.52.189" dyno=web.1 connect=1ms service=20ms status=302 bytes=101
2013-10-08T17:10:35.725344+00:00 app[web.1]: Started GET "/users/password" for 24.87.52.189 at 2013-10-08 17:10:35 +0000
2013-10-08T17:10:35.883843+00:00 app[web.1]: Rendered devise/sessions/new.html.erb within layouts/application (9.6ms)
2013-10-08T17:10:35.883843+00:00 app[web.1]: Rendered layouts/_shim.html.erb (0.0ms)
2013-10-08T17:10:35.883843+00:00 app[web.1]: Rendered layouts/_header.html.erb (1.3ms)
2013-10-08T17:10:35.883843+00:00 app[web.1]: Rendered layouts/_footer.html.erb (1.0ms)
2013-10-08T17:10:35.883843+00:00 app[web.1]: Completed 200 OK in 23ms (Views: 19.6ms | ActiveRecord: 0.0ms)
2013-10-08T17:10:35.354246+00:00 app[web.1]: Rendered layouts/_header.html.erb (0.9ms)
2013-10-08T17:10:35.735631+00:00 app[web.1]: Parameters: {"id"=>"password"}
2013-10-08T17:10:35.883843+00:00 app[web.1]: Processing by Devise::SessionsController#new as */*
**2013-10-08T17:10:35.735631+00:00 app[web.1]: Completed 401 Unauthorized in 3ms**
2013-10-08T17:10:35.735631+00:00 app[web.1]: Processing by UsersController#show as */*
2013-10-08T17:10:35.883843+00:00 app[web.1]: Rendered devise/shared/_links.erb (0.5ms)
2013-10-08T17:10:35.856371+00:00 app[web.1]: Started GET "/users/sign_in" for 24.87.52.189 at 2013-10-08 17:10:35 +0000
2013-10-08T17:09:38.753083+00:00 heroku[router]: at=info method=GET path=/users/sign_in host=www.skalefree.net fwd="24.87.52.189" dyno=web.1 connect=14ms service=45ms status=200 bytes=3688
2013-10-08T17:10:35.892408+00:00 heroku[router]: at=info method=GET path=/users/sign_in host=skalefree.net fwd="24.87.52.189" dyno=web.1 connect=2ms service=40ms status=200 bytes=3783
如您所见,我在那里有一个未经授权的 301。有谁知道这个问题的解决方案?
这是我的路线:
devise_for :users, skip: :registrations
devise_scope :user do
resource :registration,
only: [:new, :create, :edit, :update],
path: 'users',
path_names: { new: 'sign_up' },
controller: 'devise/registrations',
as: :user_registration do
get :cancel
end
end
我的用户模型:
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
还有我的初始化程序:
config.reset_password_keys = [ :email ]
在此先感谢您的帮助!