Mailer with no implicit template #6801

Merged
merged 1 commit into from Jun 20, 2012

Conversation

Projects
None yet
2 participants
Contributor

dmathieu commented Jun 20, 2012

Currently, if we send an email and use the implicit template with it but not template exists, nothing fails.
I don't think that's the behavior usually intended.

This will raise an ActionView::MissingTemplate in that case.
It already occurs like this when rendering an explicit template.

actionmailer/lib/action_mailer/base.rb
@@ -733,6 +733,7 @@ def collect_responses_and_parts_order(headers) #:nodoc:
def each_template(paths, name, &block) #:nodoc:
templates = lookup_context.find_all(name, Array(paths))
+ raise ActionView::MissingTemplate.new([paths], name, [paths], false, 'mailer') if templates.empty?
@rafaelfranca

rafaelfranca Jun 20, 2012

Owner
def each_template(paths, name, &block) #:nodoc:
  templates = lookup_context.find_all(name, Array(paths))

  if templates.empty?
    raise ActionView::MissingTemplate.new([paths], name, [paths], false, 'mailer')
  else  
    templates.uniq { |t| t.formats }.each(&block)
  end
end

Is not better to read?

@dmathieu

dmathieu Jun 20, 2012

Contributor

All right. I have updated it accordingly.

Owner

rafaelfranca commented Jun 20, 2012

Please add a CHANGELOG entry

Contributor

dmathieu commented Jun 20, 2012

I have made the code change you suggested and added the changelog entry. Thanks @rafaelfranca

@ghost ghost assigned rafaelfranca Jun 20, 2012

rafaelfranca added a commit that referenced this pull request Jun 20, 2012

@rafaelfranca rafaelfranca merged commit c1c4ecb into rails:master Jun 20, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment