module ActionMailerWithRequest::RequestAccess

Public Instance Methods

request() click to toggle source

Get the current request. This assists in making request-based e-mail addresses. For example:

mail :from => "no-reply@#{request.try(:domain) || 'example.com'}", .....

Remember if the mailer is delivered outside the context of a request then this method returns nil. Hence the try(:domain) as well as the fallback domain.

# File lib/actionmailer_with_request.rb, line 50
def request
  Thread.current["actiondispatch.request"]
end