gpt4 book ai didi

ruby-on-rails - 如何使用 Premailer-Rails gem 为我的 HTML 电子邮件指定样式表?

转载 作者:行者123 更新时间:2023-12-04 01:12:25 24 4
gpt4 key购买 nike

我有一个样式表,我想在我的 HTML 电子邮件中的路径中使用:
app/vendor/assets/stylesheets/inspinia/email_templates/email-styles.css
我正在使用 Premailer-Rails我的电子邮件样式的 gem。

在我的 mailer.html.erb布局,我有以下内容:

<%= stylesheet_link_tag "inspinia/email_templates/email-styles.css", media: 'all' %>

但是,在 Heroku 上的日志中,我收到以下消息:
app[web.1]: [923202d9-b3f1-4b9a-9f42-7b70dcc01d92] Started GET "/stylesheets/inspinia/email_templates/email-styles.css" for 54.167.56.21 at 2016-12-23 23:25:08 +0000
app[web.1]: [923202d9-b3f1-4b9a-9f42-7b70dcc01d92]
2016-12-23T23:25:08.286725+00:00 app[web.1]: [923202d9-b3f1-4b9a-9f42-7b70dcc01d92] ActionController::RoutingError (No route matches [GET] "/stylesheets/inspinia/email_templates/email-styles.css"):

那么如何在生产中找出/指定此样式表的正确路径?

最佳答案

尝试搬家 email-styles.css/public/assets/文件夹,或将其添加到 Assets 管道。
Premailer-rails 维基:

  1. File System: If there's a file inside public/ with the same path as in the URL, it is read from disk. E.g. if the URL is http://cdn.example.com/assets/email.css the contents of the file located at public/assets/email.css gets returned if it exists.

  2. Asset Pipeline: If Rails is available and the asset pipeline is enabled, the file is retrieved through the asset pipeline. E.g. if the URL is http://cdn.example.com/assets/email-fingerprint123.css, the file email.css is requested from the asset pipeline. That is, the fingerprint and the prefix (in this case assets is the prefix) are stripped before requesting it from the asset pipeline.

关于ruby-on-rails - 如何使用 Premailer-Rails gem 为我的 HTML 电子邮件指定样式表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41308904/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com