From 63e1541aa317a714fb0561ecc51da581660f73c1 Mon Sep 17 00:00:00 2001 From: Patrick Gansterer Date: Wed, 23 Jan 2019 23:00:33 +0100 Subject: [PATCH] Use the default locale when sending mails to suppliers --- app/mailers/mailer.rb | 6 ++++++ app/models/order.rb | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index 2ce6403c..8eb100c0 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -125,6 +125,12 @@ class Mailer < ActionMailer::Base end end + def self.deliver_now_with_default_locale(&block) + I18n.with_locale(FoodsoftConfig[:default_locale]) do + self.deliver_now &block + end + end + def self.deliver_now message = yield message.deliver_now diff --git a/app/models/order.rb b/app/models/order.rb index 410b4821..c53df8a7 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -266,7 +266,9 @@ class Order < ApplicationRecord end def send_to_supplier!(user) - Mailer.order_result_supplier(user, self).deliver_now + Mailer.deliver_now_with_default_locale do + Mailer.order_result_supplier(user, self) + end update!(last_sent_mail: Time.now) end