【发布时间】:2012-01-22 03:50:30
【问题描述】:
我正在尝试允许用户使用 Devise 的 recoverable 选项重置他们的密码。这似乎对我不起作用。
我扩展了Devise::PasswordsController,使其不使用应用程序布局。
class PasswordsController < Devise::PasswordsController
layout false
end
在我的路由中,我确保使用了我的密码控制器。
devise_for :users, :controllers => {:passwords => "passwords"}
resources :passwords
这是我的用户模型,因此您可以看到我有 :recoverable 选项。
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
在我的登录页面上,我有(我正在使用 haml):
...
= link_to "Forgot your password?", new_password_path(resource_name)
这个链接正确地把我带到http://localhost:3000/users/password/new。这是在那里找到的表格:
%h2 Forgot your password?
= form_for(resource, as: resource_name, url: password_path(resource_name), html: { :method => :post }) do |f|
= devise_error_messages!
%div
= f.label :email
%br/
= f.email_field :email
%div= f.submit "Send me reset password instructions"
但是,当我单击按钮时,这似乎试图将我带到错误的地方。每次都失败,并且在服务器日志中没有显示任何电子邮件。
它将我重定向到:http://localhost:3000/passwords/user 并告诉我:
路由错误
No route matches "/passwords/user"
知道如何继续吗?我认为使用 recoverable 选项比这更容易。我做错了什么?
更新 作为记录,我刚刚删除了我所做的一切,并尝试使用标准设计控制器,我修改了我的应用程序布局,以便它不会导致错误,并且一切正常。所以我只需要一种从密码重置页面中删除应用程序布局的好方法。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 passwords devise