Add variant support to ActionMailer

Hi all,

In our current project we are managing a multi-domain Rails app and we sometimes need the views to specialize depending on the domain that is running. We used to use a separate view path that we prepended to achieve that and since the release of Rails 4.1 we started using variants for that purpose.

However, it seems variants are not supported for ActionMailer. Since AbstractController::Rendering only checks if request is defined and, subsequently, if request.variant is present, we are currently hacking the same behaviour by defining a request method on our Mailer like:

def request
@_request ||= domain)

I guess the variant feature was originally implemented with content negotiation in mind, but at least in our use case, it works beautifully for alternative purposes as well. I am willing to add variants support for ActionMailer, if there is any interest/willingness to do so.


Ufuk Kayserilioglu