Remove specific error message from Rails Devise

252 Views Asked by At

In Devise, when confirmation instructions are resent and the email doesn't exist in the database, we get the error

Email not found

However, due to security, I want to remove this specific error.

I'm using custom controllers but the confirmation#create method is just invoking super. Under that, I've removed the email field from the errors using

resource.errors.delete('email')

Printing out the errors (in the controller) after the fact shows nothing for email. However, when the request goes through and I print the resource.errors object in the shared errors partial, the error is still there.

Is there any way to remove this error completely? I'm assuming some other action is happening after the #create method that's injecting the error again.

Full method

def create
  super
  resource.errors.delete('email')
end

Confirmation of deletion:

enter image description here

Confirmation that error persists after redirect:

enter image description here

0

There are 0 best solutions below