如何在Rails中预览电子邮件? [英] How do I preview emails in Rails?

查看:129
本文介绍了如何在Rails中预览电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个愚蠢的问题,但是当我在Rails中放置一个HTML电子邮件时,是否有一个特别简单的内置方式来在浏览器中预览模板,或者我需要编写一些自定义控件

解决方案

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆