-
-
Notifications
You must be signed in to change notification settings - Fork 202
Open
Description
Bug Report
Describe the Bug:
ActionMailers that use keyword arguments in their methods are not able to be used in Noticed because there is not support for keyword arguments.
Example mailer:
class User::EmergencyPasskeyRegistrationMailer < ApplicationMailer
def emergency_registration_request(emergency_passkey_registration:)
user = emergency_passkey_registration.user
token = emergency_passkey_registration.generate_token_for(:emergency_registration)
# ...To Reproduce:
- Step 1
- Step 2
- ...
Expected Behavior:
These mailers should work, since keyword arguments are a common Ruby feature
Possible Fix:
I've got the following override from a patched subclass I made, submitting as a PR shortly.
def deliver
mailer = fetch_constant(:mailer)
email = evaluate_option(:method)
args = evaluate_option(:args) || []
kwargs = evaluate_option(:kwargs) || {}
mailer_instance = mailer.with(params)
if kwargs.present?
mail = mailer_instance.public_send(email, **kwargs)
else
mail = mailer_instance.public_send(email, *args)
end
(!!evaluate_option(:enqueue)) ? mail.deliver_later : mail.deliver_now
endChecklist:
- I have searched for similar issues and couldn't find any
- I have checked the documentation for relevant information
- I have included all the required information
rromanchuk
Metadata
Metadata
Assignees
Labels
No labels