Reputation: 91
I've got to make an update to a rails app using Devise to show the number of minutes left if you are locked out while trying to login to the application.
In the devise.en.yml file I've got:
en:
devise:
confirmations:
confirmed: "Your email address has been successfully confirmed."
send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
failure:
already_authenticated: "You are already signed in."
inactive: "Your account is not activated yet."
invalid: "Invalid %{authentication_keys} or password."
locked: "Your account is locked. Please try again in %{number_of_minutes} minutes"
last_attempt: "You have one more attempt before your account is locked."
not_found_in_database: "Invalid %{authentication_keys} or password."
timeout: "Your session expired. Please sign in again to continue."
unauthenticated: "You need to sign in or sign up before continuing."
I have the variable called 'number_of_minutes' in the locked: error message but no matter what I try I get:
missing interpolation argument :number_of_minutes in "Your account is locked. Please try again in %{number_of_minutes} minutes" ({:resource_name=>:user, :authentication_keys=>"E-mail address"} given)
I've added it to the view, the overridden SessionsController, set default locale, tried a whole bunch of online recommendations and no luck.
Any ideas?
Cheers, Adrian
Upvotes: 1
Views: 933
Reputation: 61
The variables has to be passed as a Hash, not just a value.
In your view, you should try to call the translation with :
I18n.t 'devise.failure.locked', number_of_minutes: <value>
Replacing with the variable you need
Upvotes: 1