2

我正在使用 Rails 3 应用程序,需要调整密码重新发送视图上的错误消息。如果用户输入电子邮件地址并提交,目前,应用程序将显示以下错误消息:

Email not found

我需要将此错误消息更改为:

We don't have an account with that e-mail address. Maybe you used another address?

我知道您可以在设计 YML 文件中进行调整,但不确定如何执行此操作……有什么建议吗?

工作代码

class PasswordsController < Devise::PasswordsController
  def create
    user = User.find_by_email(params[:user][:email])

    if user.nil?
      flash.now[:notice] = "We don't have an account with that e-mail address. Maybe you used another address?"
    end

    super
  end
end
4

1 回答 1

2

您可以尝试使用 before_filter 来检查电子邮件是否存在于数据库中,如果不存在,它会将您重定向到密码重置表单并发出快速通知

于 2012-06-20T18:47:16.777 回答