Rails - Install multiple layouts for multi-page email with mailing templates

So, Rails 2.2 added mailing list layouts, which is great, except that I can't figure out how to make them work when I send a multi-page email address ... it wraps my mail content with the same layout for text / plain and text / html version. I want my layout to bypass either just the text / html version, or have the ability to have a separate layout for each.

Has anyone come across this? I have not seen mention of this elsewhere,

Cameron

+2
ruby ruby-on-rails actionmailer
source share
1 answer

In the future, the link to the blog post above, amended in the second blog post, is below the total credit for the aforementioned blog post. Solution Blog Post

Add this code to the environment.rb file so that the mail client does not apply layouts to text email messages. He also has a check that will not allow him to contradict the exception notification plugin.

# Do not use the mailer layout template for plain text emails module ActionMailer class Base private def candidate_for_layout?(options) (!options[:file] || !options[:file].respond_to?(:content_type) || options[:file].content_type != 'text/plain') && !@template.send(:_exempt_from_layout?, default_template_name) end end end 
+3
source share

All Articles