【发布时间】:2012-05-26 08:17:08
【问题描述】:
我在 Rails 中使用 Devise 身份验证 gem。
如何显示来自 devise.en.yml 的消息:
send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes'
密码恢复电子邮件发送后,而不是被重定向到站点的根目录?
更新:
我在 devise_controller.rb 中发现了一段有趣的代码:
def successfully_sent?(resource)
notice = if Devise.paranoid
resource.errors.clear
:send_paranoid_instructions
elsif resource.errors.empty?
:send_instructions
end
if notice
set_flash_message :notice, notice if is_navigational_format?
true
end
end
设置断点显示正在调用正确的行,将 :send_instructions 分配给 notice ,调用了 set_flash_message,但是我看不到这一切的结果,因为我我立即重定向到根路径。
【问题讨论】:
-
检查 flash[:notice] 是否被分配 + 你是否有块来呈现 flash 消息 + 查看日志可能你有双重重定向
-
我有 flash[:notice] 块,但不知道额外的重定向可能隐藏在哪里。
-
添加你是否检查过 flash[:notice] 已分配?
-
是的,我有条件。顺便说一句:它如何防止重定向?
标签: ruby-on-rails devise confirmation password-recovery