Rails - setting multiple layouts for a multipart email with mailer templates

て烟熏妆下的殇ゞ 提交于 2019-12-06 06:12:33

For future reference the solution in the blog post above amended in a second blog post is given below all credit to the above mentioned blog post. Solution blog post

Add this code to your environment.rb file to stop the mailer from applying layouts to plain text emails. It also has a check that will stop it from conflicting with 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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!