如何在Rails中预览电子邮件? [英] How do I preview emails in Rails?
本文介绍了如何在Rails中预览电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
Action Mailer现在具有内置的查看 Rails 4.1 中的电子邮件。例如,请查看:
#位于test / mailers / previews / notifier_mailer_preview.rb
类NotifierPreview< ActionMailer :: Preview
#可以从http:// localhost:3000 / rails / mailers / notifier / welcome
def welcome
Notifier.welcome(User.first)
end
end
This might be a dumb question but when I'm putting together an HTML email in Rails, is there a particularly easy built-in way to preview the template it in the browser or do I need to write some sort of custom controller that pulls it in as its view?
解决方案
Action Mailer now has a built in way of previewing emails in Rails 4.1. For example, check this out:
# located in test/mailers/previews/notifier_mailer_preview.rb
class NotifierPreview < ActionMailer::Preview
# Accessible from http://localhost:3000/rails/mailers/notifier/welcome
def welcome
Notifier.welcome(User.first)
end
end
这篇关于如何在Rails中预览电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文