wmoxam (owner)

Revisions

gist: 91411 Download_button fork
public
Public Clone URL: git://gist.github.com/91411.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module ActionMailer
  class Base
    # I want layouts to apply to email parts seperately!
    # An html layout is useless for the text portion and vise versa
    # peanut butter monkey patch time!
    def render_message(method_name, body, layout = nil)
      if method_name.respond_to?(:content_type)
        @current_template_content_type = method_name.content_type
      end
      render :file => method_name, :body => body, :layout => layout
    ensure
      @current_template_content_type = nil
    end
  end
end
 
----------------
In the mailer:
 
part :content_type => "text/html",:body => render_message("conversation_message.text.html.haml", @body, 'user_email_html')
part :content_type => "text/plain", :body => render_message("conversation_message.text.plain.erb", @body, 'user_email_text'), :transfer_encoding => "base64"