Question

I'm finishing the different localizations of my site and i got a little issue in Devise email templates.

In confirmation email for instance, i have translated it all, but the link to confirm the account is auto generated using this snippet:

<%= link_to t('devise.mailer.confirmation_instructions.confirm_link'), confirmation_url(@resource, :confirmation_token => @token) %>

This auto generated link points always to my .com web version and i want it to be conditional depending on the domain (.com/.es). When the link is not auto generated i can accomplish that using:

if request.host.split('.').last == "com"

or

if request.host.split('.').last == "es"

But in this case, i don't know how i can do it.

Any suggestion?

Thanks.

Was it helpful?

Solution

You could add the :host param to your confirmation_url(@resource, :confirmation_token => @token), and look up the correct host in your translation table:

confirmation_url(@resource, :confirmation_token => @token, host: t('host'))

In your yaml file, you 'translate' the correct host for the user's language, like

en:
  host: 'www.example.com'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top