diff options
author | Colin Curtin <colin@procore.com> | 2008-11-20 13:39:34 -0800 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-11-21 04:09:14 +0530 |
commit | 1d4554d766dbf8391689d91b4b88766757051c68 (patch) | |
tree | a71176f9a7bbf213d5902c7d77783959ede852ba /actionmailer/lib/action_mailer | |
parent | 84583657f40e5554c496fb24dfbc1921f11b0498 (diff) | |
download | rails-1d4554d766dbf8391689d91b4b88766757051c68.tar.gz rails-1d4554d766dbf8391689d91b4b88766757051c68.tar.bz2 rails-1d4554d766dbf8391689d91b4b88766757051c68.zip |
ActionMailer should respect content type when choosing layouts
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'actionmailer/lib/action_mailer')
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 19ce77ea5a..e41c88d81b 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -549,7 +549,12 @@ module ActionMailer #:nodoc: end def render_message(method_name, body) + if method_name.respond_to?(:content_type) + @current_template_content_type = method_name.content_type + end render :file => method_name, :body => body + ensure + @current_template_content_type = nil end def render(opts) @@ -568,7 +573,11 @@ module ActionMailer #:nodoc: end def default_template_format - :html + if @current_template_content_type + Mime::Type.lookup(@current_template_content_type).to_sym + else + :html + end end def candidate_for_layout?(options) @@ -588,7 +597,9 @@ module ActionMailer #:nodoc: end def initialize_template_class(assigns) - ActionView::Base.new(view_paths, assigns, self) + template = ActionView::Base.new(view_paths, assigns, self) + template.template_format = default_template_format + template end def sort_parts(parts, order = []) |