render :inline in ActionMailer

Hello everyone,

while attempting to figure out how to render an inline template as body of a
mail message in an ActionMailer I am somewhat lost and hope that somebody on
the list can point me into the right direction.

My current code looks like this (with minor deletions to improve readability):

-- 8< --
class RegistrationMailer < ActionMailer::Base
  def confirmation(registration)
    recipients "#{registration.full_name} <#{}>"
    from "<#{registration.event.organizer_alias_email}>"
    tmpl = registration.event.registration_confirmation_template
    subject tmpl.subject
    part "text/plain" do |p|
      p.body render :inline => tmpl.body, :registration => registration
-- 8< --

Unfortunately, calling render throws an exception about a nil object:

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each

-- 8< --
-- 8< --

Line 310 maps to the "elsif" branch in base.rb, so most likely
controller.request.template_format is nil:

   def template_format
     if defined? @template_format
     elsif controller && controller.respond_to?(:request)
       @template_format = controller.request.template_format.to_sym
       @template_format = :html

But, what would be the right way to set it?

I know that my approach somewhat violates the MVC pattern. An alternative
would probably be to call render from within the corresponding view.