【问题标题】:rails: include html in a mail_to linkrails:在 mail_to 链接中包含 html
【发布时间】:2011-05-12 14:09:38
【问题描述】:

我正在寻找一种在 mail_to 链接中包含 html 的方法,以便我可以在此电子邮件的正文中自动包含横幅。

感谢任何提示

马库斯

【问题讨论】:

    标签: html ruby-on-rails email mailto


    【解决方案1】:

    轨道 3

    mail_to "email@example.com", raw(image_tag("/path/to/banner.png"))
    

    Rails 2.x

    mail_to "email@example.com", image_tag("/path/to/banner.png")
    

    请参阅mail_to 帮助程序的文档。

    【讨论】:

    • raw()是什么方法?我的 Rails (2.3.5) 不知道这个方法!
    • 这是一个 Rails 3 助手。如果使用 Rails 2 就更简单了。我更新了回复。
    • 对不起,我的问题是错误的......但你回答正确!你可以在这里找到我真正的问题:stackoverflow.com/questions/4224751
    【解决方案2】:

    在带有actionview-encode_mail_to 的rails 4 中,您可以像(Haml 语法)一样进行操作:

    = mail_to 'email@example.com', encode: 'javascript' do
      = image_tag('contact_email.png')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-29
      • 1970-01-01
      • 2021-03-22
      • 1970-01-01
      • 2011-02-06
      • 1970-01-01
      • 2016-10-26
      • 2021-06-26
      相关资源
      最近更新 更多