Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't support html layout #15

Closed
raykin opened this issue Dec 11, 2014 · 3 comments
Closed

can't support html layout #15

raykin opened this issue Dec 11, 2014 · 3 comments

Comments

@raykin
Copy link

raykin commented Dec 11, 2014

Ex:

class UserMailer < ActionMailer::Base
  layout 'general_mailer'
  default from: "*** <[email protected]>"

  def welcome(uid)
    @user = User.find(uid)
    mail to: @user.email, subject: 'Welcome to PathSource!'
  end
end

Run UserMailer.welcome(1).deliver will not render the layout at all. But layout file general_mailer.html.erb does exist.

When I debug into the source, I find on this line https://github.com/rails/rails/blob/master/actionview/lib/action_view/renderer/template_renderer.rb#L86 it raise ActionView::MissingTemplate, but return true on https://github.com/rails/rails/blob/master/actionview/lib/action_view/renderer/template_renderer.rb#L90.

So it only search for md format layout. I don't know why it happens.

@raykin
Copy link
Author

raykin commented Dec 11, 2014

when I change filename to general_mailer.md.erb, it works.
So is that mean only md format file can be used after installing maildown?

@schneems
Copy link
Member

This is all baked into the way that action mailer does emails. It needs a layout with the same mimetype or action view doesn't know how to render the view.

Since maildown generates two different email bodies, it wouldn't know how to only use the html or the text layout.

You can dig in and try to add this functionality, but honestly this whole library is a giant hack.

@raykin raykin closed this as completed Dec 12, 2014
@raykin
Copy link
Author

raykin commented Dec 13, 2014

I found a workaround, renaming general_mailer.md.erb to general_mailer.erb works for all formats.
Actually the layout formats is decided by template formats.
Ex: if rendered template is welcome.html.erb, ActiveMailer will look for html layout, if template is welcome.md.erb, ActiveMailer will look for md layout.
So layout general_mailer.erb can match for all format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants