actionmailer set host dynamic based on .LTD app.com/ app.fr
-
17-06-2021 - |
Pregunta
Im having 2 different languages in my rails app and would like to be able to set the domain name set in the right language. For example if a user registers from app.FR I want in below example the extension .FR used instead of .COM is there a way to do that?
config.action_mailer.asset_host = "http://app.com"
config.action_mailer.default_url_options = {:host => 'app.com'}
Solución
It seems that the solution is setting a before filter in your ApplicationController and make a function like:
def set_mailer_host
ActionMailer::Base.default_url_options[:host] = request.host_with_port
end
Remember when sending mail from rails console this will not work since rails console will not pass true ActionController.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow