Question

How can I access ExceptionNotifier variables such as sender_address or exception_recipients in my custom mailer class? Since ExceptionNotifier is implemented as Rack middleware, I'm not sure how to go about it.

Was it helpful?

Solution

I still don't know how to access the ExceptionNotifier variables, so the workaround I decided on is to add these variables to Rails config instead, and use them to configure both ExceptionNotifier and my custom mailer:

config.exception_subject_prefix = "[App Error] "
config.exception_sender = "support@example.com"
config.exception_recipients = %w{support@example.com}

config.middleware.use "::ExceptionNotifier",
                      :email_prefix => config.exception_subject_prefix,
                      :sender_address => %{ #{config.exception_sender} },
                      :exception_recipients => config.exception_recipients

The config variables can be accessed elsewhere as Rails.configuration.exception_sender and so on.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top