#5769 ActionMailer Implicit Render Bug

Hi all,

I posted ticket #5769 a couple of months back and have only just gotten around to diving into ActionMailer myself. It turns out that the implicit rendering logic is faulty in 1.2.5 (and back at least as far as 1.2.3). I would post a patch but I don't seem to be able to create a Trac account.

Currently the ActionMailer.create! method does this...

template_exists = @parts.empty? template_exists ||= Dir.glob("#{template_path}/#{@template}.*").any? {

i> File.basename(i).split(".").length == 2 }

@body = render_message(@template, @body) if template_exists

This implicit render is not meant to occur if some parts have been defined by the user method. Unfortunately there is a problem here as, if the template is present, template_exists still gets set to true irrespective of the @parts logic. In order to preserve the timesaving of not checking for a template if parts exist but actually make the above logic do what it's supposed to, may I suggest...

if @parts.empty?     template_exists = Dir.glob("#{template_path}/#{@template}.*").any? { |i| File.basename(i).split(".").length == 2 }     @body = render_message(@template, @body) if template_exists end