Rails/Devise - Add ruby code in a locale file?
-
25-09-2019 - |
Question
I would like to know if there is a way to add ruby code in a locale file. For example:
devise:
failure:
unconfirmed: 'You have to confirm your account before continuing. <%= link to "send confirmation instructions?", user_confirmation_path %>'
Thanks for your help!
Solution
The way I have solved this in the past is:
devise:
failure:
unconfirmed: 'You have to confirm your account before continuing. {{confirm_link}}.'
confirm_link_text: "send confirmation instructions?"
Then where you need the output:
t('devise.failure.unconfirmed',
:confirm_link => link_to(
t('devise.failure.confirm_link_text'),
user_confirmation_path)
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow