如何集成“预邮件程序”带导轨
如何将“premailer”gem 与 Rails (3.0.7) 项目集成?我目前的邮件中有:
def welcome(user)
@user = user
mail to: user.email, subject: "Welcome"
end
但我不知道如何集成该库。我需要打电话:
premailer = Premailer.new(html)
html = premailer.to_inline_css
但是,我不确定如何通过邮件操作访问电子邮件的内容。
How does one integrate the 'premailer' gem with a Rails (3.0.7) project? I currently have in my mailer:
def welcome(user)
@user = user
mail to: user.email, subject: "Welcome"
end
But I can't figure out how to integrate the library. I need to call:
premailer = Premailer.new(html)
html = premailer.to_inline_css
However, I'm not sure how to access the contents of my email from a mailer action.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
看看我最近写的简单的 premailer-rails gem 。它使用 Rails 邮件挂钩来进行转换。
Have a look at the simple premailer-rails gem I recently wrote. It uses Rails mailer hooks to do the conversion.
尝试:
Try:
对于 Rails 4 用户,您可以:
添加宝石
将其添加到您的样式表(Haml)中:
由于某种原因,它无法使用正常的 stylesheet_link_tag
这就是我所要做的。希望这有帮助!
For Rails 4 users you can:
add the gems
add this to your stylesheet (Haml):
for some reason it wasn't working with a normal stylesheet_link_tag
That's all I had to do. Hope this help!
或者
or