Forum: Ruby on Rails rails3 mailer how to use a safe mailer not taking in account the I18n.locale

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2011-05-21 12:18
(Received via mailing list)
in a multilingual site dev, I need to send localized emails...
as I need to define the @template in the mailer method, I don't want
to take in account the I18n.locale:

I wrote in my mailer method

    def welcome(user, message)
      @user = user
      language = user.language  # es_ES testing
      @template = "#{ActionMailer::Base::template_root}/user_mailer/
      @message = message
      mail(:to =>, :subject => "Welcome") do |format|
          format.html { render :layout => "/mailer/
sbga_user_mail", :template => @template }
          format.text {render :layout => false, :template =>

and I have the views :
----- user_mailer
---------- -en_GB
--------------- welcome.html.erb
--------------- welcome.text.erb
--------- -es_ES
--------------- welcome.html.erb
--------------- welcome.text.erb

but sending an email to a Spanish user,
UserMailer.welcome(current_user, "Lorem ipsum dolor").deliver , with
I18n.locale = :en_GB   raises  an error :

ActionView::MissingTemplate: Missing template /Users/yves/Sites/rails/
testsbga/app/views/user_mailer/es_ES/welcome with
{:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml, :haml],
:formats=>[:html], :locale=>[:en_GB]}
in view paths

as I18n.locale is defined to :en_GB..
it seems to be looking for  welcome.en_GB.html.erb  in /views/

how can I inform mailer that I don't want to use locale views .... ?
This topic is locked and can not be replied to.