相关疑难解决方法(0)

我如何在Mailer中使用资产?

我无法在邮件程序中使用任何形式的资产管道,而是使用Mailer本身或视图.

以下生成并清空src图像标记.

<%= image_tag "emails/header-general.png" %>
Run Code Online (Sandbox Code Playgroud)

空图像标记如下所示:

img alt ="Header-general"

以下通过模型附加文件并在视图中使用它的形式会附加一个空图像.

attachments.inline['header.jpg'] = 'emails/header-general.png'
...
<%= image_tag attachments['header.png'] %>
Run Code Online (Sandbox Code Playgroud)

我确实检查了路径,甚至尝试了多条路径等等但没有运气.请帮忙.在电子邮件中包含图像的任何形式都会有所帮助.

这是生产环境.

Xenium::Application.configure do
# Settings specified here will take precedence over those in config/application.rb

# Code is not reloaded between requests
config.cache_classes = true

# Full error reports are disabled and caching is turned on
config.consider_all_requests_local       = false
config.action_controller.perform_caching = true

# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false

# Compress JavaScripts …
Run Code Online (Sandbox Code Playgroud)

assets ruby-on-rails actionmailer ruby-on-rails-3.1 asset-pipeline

6
推荐指数
2
解决办法
3647
查看次数