Hi! I had the same problem and what I've managed to come up with is hackish, but transparent solution. This way you can use ActiveMailer's #deliver_later and it's hashbang friend without worrying about passing locale yourself. So much better to leave grizzly implementation details out of the sight ;)
You can find it as a gist here: http://git.io/vt9pt Best regards, Sija PS. If someone would come up with similar solution, but applied instead on the level of ActiveJob I'd be happy to hear about it :) On Thursday, October 23, 2014 at 11:29:34 AM UTC+2, Carlos Antonio da Silva wrote: > > Rather than doing something like: > > *I18n.with_locale(:en) { Mailer.zomg(foo, bar).deliver_later }* > > You can do > > *Mailer.zomg(:en foo, bar).deliver_later* > > And within the mailer > > *def zomg(locale, foo, bar)* > * I18n.with_locale(locale) do* > * ....* > * end* > *end* > > Right now that's the simplest thing that I can think of, and it's so > simple that I'm not even sure Rails should have any special handling for > that - but maybe it should. > > On Thu, Oct 23, 2014 at 4:57 AM, Igor Kapkov <igas...@gmail.com > <javascript:>> wrote: > >> Yeah, I understand how to do it now, but don't understand how it'll work >> in 4.2. Let's look at example. I send confirmation instructions >> `UserMailer.confirmation(@user).deliver_later` and I have 2 views >> `app/views/user_mailer/confirmation.en.html.erb` >> & `app/views/user_mailer/confirmation.ru.html.erb`. And `deliver_later` >> just add the job >> https://github.com/rails/rails/blob/04b40b3debebc24e11a1d9c81ea313125500185b/actionmailer/lib/action_mailer/delivery_job.rb >> >> but this job wont know nothing about user locale. >> >> I'm not asking for help how to solve this, I just worried that this >> scenario currently not mentioned or solved as I see. >> >> среда, 22 октября 2014 г., 23:12:24 UTC+8 пользователь Carlos Antonio da >> Silva написал: >>> >>> You should probably be passing in the locale you want as an argument to >>> your mailers, and set the locale there before actually creating the mail >>> object/rendering the view. >>> >>> On Wed, Oct 22, 2014 at 1:07 PM, Mohamed Wael Khobalatte < >>> wael.kh...@gmail.com> wrote: >>> >>>> There shouldn't be any problem since deliver_later will simply invoke >>>> your deliver_now at some point, and that should run as you expect. >>>> >>>> On Wed, Oct 22, 2014 at 2:31 PM, Igor Kapkov <igas...@gmail.com> wrote: >>>> >>>>> Hi all, >>>>> >>>>> previously if we needed in sending a mail in different locale we used >>>>> `I18n.with_locale`. I didn't find any about that in sources and >>>>> docs/guides. How it'll work with `deliver_later` and ActiveJob? >>>>> >>>>> Best Regards, >>>>> Igas >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Ruby on Rails: Core" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to rubyonrails-co...@googlegroups.com. >>>>> To post to this group, send email to rubyonra...@googlegroups.com. >>>>> Visit this group at http://groups.google.com/group/rubyonrails-core. >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> >>>> >>>> -- >>>> Mohamed Wael Khobalatte >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Ruby on Rails: Core" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to rubyonrails-co...@googlegroups.com. >>>> To post to this group, send email to rubyonra...@googlegroups.com. >>>> Visit this group at http://groups.google.com/group/rubyonrails-core. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >>> >>> -- >>> At. >>> Carlos Antonio >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonrails-co...@googlegroups.com <javascript:>. >> To post to this group, send email to rubyonra...@googlegroups.com >> <javascript:>. >> Visit this group at http://groups.google.com/group/rubyonrails-core. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > At. > Carlos Antonio > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.