Hi there,
I've configured my authentication keys to look up :email
as well as another key, I'll call it :account_id
. In the form I'm setting the account_id in a hidden field. When authentication fails, the flash message says "Invalid email, account_id, or password". I want to exclude the 'account_id' from that message, so I have my devise.en.yml file read as follows:
en:
devise:
failure:
...
invalid: 'Invalid email or password.'
...
Unfortunately no matter what I do I cannot get devise to read this file, it insists upon using it's native devise.en.yml file. Is this a bug or am I missing a configuration?
Thanks
There's nothing special, as long as it's in your locale folder and the app is restarted after the file is added, it should work.
You'll need to provide us with more information on how to reproduce the problem, if possible an example app, to investigate. Thanks!
@jmarchello I am having the same problem, were you able to find a way to fix the issue? I can change some of the messages and have them take effect, for example "unauthenticated", but "invalid" will not pick up my changes from the devise.en.yml file.
Edit: it turns out I had to make the change in config/locales/en.yml, not devise.en.yml. For anyone else wondering.
To customize messages shown in english,
config/locales/devise.en.yml
and change the message you want to display.en:
devise:
failure:
user: #this is the line you add
already_authenticated: "Custom already authenticated message."
inactive: "Custom account not active message."
sessions:
user: # your devise resource
signed_in: "Custom signed in message"
signed_out: "Custom signed out message"
Source: Devise README
Remember indentations in yml files are important, check everything is in order, and use spaces instead of tabs.
I ran into this issue specifically with the :invalid
key. In my case the issue was not with the translation files themselves, but there was another error key that also generate the same message as :invalid
. In my particular case :not_found_in_database
- this key will be used instead of :invalid
under certain circumstances.
This key was added in 4.5.0, so this can happen to anyone upgrade to 4.5.0 or later.
Most helpful comment
I ran into this issue specifically with the
:invalid
key. In my case the issue was not with the translation files themselves, but there was another error key that also generate the same message as:invalid
. In my particular case:not_found_in_database
- this key will be used instead of:invalid
under certain circumstances.This key was added in 4.5.0, so this can happen to anyone upgrade to 4.5.0 or later.