By default mailer methods expects layout in view/layouts directory by the underscored version of the mailer class name.
If mailer class is like
class UserMailer < ActionMailer::Base
def welcome_mail()
....
end
....
end
then the mailer layout name will be user_mailer.html.erb in view/layouts directory. The layout name needs to end in “_mailer” to be automatically recognized by mailer as a layout.
Content of user_mailer.html.erb should contain yield like the application layout. In this example the welcome_mail.html.erb will be rendered at yield position.
A different layout can also be set using
layout 'awesome' # it will use awesome.html.erb as the layout
class UserMailer < ActionMailer::Base
layout 'awesome'
....
end
Resource: http://guides.rubyonrails.org/action_mailer_basics.html
Subscribe to:
Post Comments (Atom)
1 comment:
Nice post.
Thanks for shearing.
Post a Comment