dennismonsewicz
dennismonsewicz

Reputation: 25552

Rails 3/Devise - Change Error Message for Password Reset

I am working with a Rails 3 App and am needing to adjust the error message on the password resent view. If a user types in an email address and submits it, currently, the app will display this error message:

Email not found

I am needing to change this error message to this:

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

I know that you can adjust this in the Devise YML file, but am not sure how to do this... any suggestions?

Working Code

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

Upvotes: 2

Views: 1049

Answers (1)

Grulli
Grulli

Reputation: 275

You could try using a before_filter that checks if the email exists in the datbase and if not the it redirects you to the password reset form with a flash notice

Upvotes: 2

Related Questions