Use template_name instead of action_name for notification mails

This is a new feature in rails 6
This commit is contained in:
Benjamin Neff 2022-07-16 19:32:46 +02:00
parent 17b84d3ddd
commit ac86c29a85
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
3 changed files with 6 additions and 9 deletions

View file

@ -40,7 +40,8 @@ module NotificationMailers
{
from: name_and_address(from_name, AppConfig.mail.sender_address),
to: name_and_address(@recipient.name, @recipient.email)
to: name_and_address(@recipient.name, @recipient.email),
template_name: self.class.name.demodulize.underscore
}
end

View file

@ -51,14 +51,10 @@ class Notifier < ApplicationMailer
end
def send_notification(type, *args)
@notification = NotificationMailers.const_get(type.to_s.camelize).new(*args)
@notification = NotificationMailers.const_get(type.camelize).new(*args)
with_recipient_locale do
self.action_name = type
mail(@notification.headers) do |format|
format.text
format.html
end
mail(@notification.headers)
end
end

View file

@ -6,7 +6,7 @@ module Workers
sidekiq_options queue: :low
def perform(*args)
Notifier.send_notification(self.class.name.gsub("Workers::Mail::", "").underscore, *args).deliver_now
Notifier.send_notification(self.class.name.demodulize.underscore, *args).deliver_now
end
end
end