6

우편 발송자 내에서 메일러 자체 또는보기와 관련된 자산 파이프 라인 양식을 사용하는 데 문제가 있습니다.메일러 내에서 자산을 사용하려면 어떻게해야합니까?

다음은 src 이미지 태그를 생성하고 비 웁니다.

<%= image_tag "emails/header-general.png" %> 

빈 이미지 태그는 다음과 같다 :

IMG의 고도가 = "헤더 총장"

모델을 통해 파일을 첨부하고 뷰를 사용하는 다음의 형태가 빈 부착 영상.

attachments.inline['header.jpg'] = 'emails/header-general.png' 
... 
<%= image_tag attachments['header.png'] %> 

나는 경로를 확인하고 심지어 여러 경로로 시도했지만 행운이 없었습니다. 도와주세요. 전자 메일 내에 이미지를 포함하는 형식이 도움이 될 것입니다.

여기에 생산 환경이 있습니다.

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 and CSS 
config.assets.compress = true 

# Choose the compressors to use 
config.assets.js_compressor = :yui 
config.assets.css_compressor = :yui 

# Don't fallback to assets pipeline if a precompiled asset is missed 
config.assets.compile = true 

# Generate digests for assets URLs 
config.assets.digest = true 

# Defaults to Rails.root.join("public/assets") 
# config.assets.manifest = YOUR_PATH 

# Specifies the header that your server uses for sending files 
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 
# config.force_ssl = true 

# See everything in the log (default is :info) 
config.log_level = :fatal 

# Use a different logger for distributed setups 
# config.logger = SyslogLogger.new 

# Use a different cache store in production 
config.cache_store = :mem_cache_store 

# Enable serving of images, stylesheets, and JavaScripts from an asset server 
#config.action_controller.asset_host = "http://asset.xenium.bg" 

# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) 
# config.assets.precompile += %w(search.js) 

# Disable delivery errors, bad email addresses will be ignored 
config.action_mailer.raise_delivery_errors = true 
#config.action_mailer.perform_deliveries = true 
config.action_mailer.delivery_method = :smtp 
config.action_mailer.smtp_settings = { 
:address    => "localhost", 
:port     => 25, 
:domain    => 'xenium.bg', 
#:user_name   => '<username>', 
#:password    => '<password>', 
#:authentication  => 'plain', 
:enable_starttls_auto => false 
} 

# Enable threaded mode 
# config.threadsafe! 

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to 
# the I18n.default_locale when a translation can not be found) 
config.i18n.fallbacks = true 

# Send deprecation notices to registered listeners 
config.active_support.deprecation = :notify 
end 

고마워요!

+0

디버깅에 대한 몇 가지 일반적인 팁으로이 질문에 대한 추가 정보를 제공합니다. #1. 평범한보기에 동일한 이미지를 표시하면 표시됩니까? 그렇다면 생성 된 이미지의 URL은 무엇입니까? # 2. 메일러 버전에서 src 속성은 실제로 비어 있습니까? 질문에 생성 된 img 태그를 포함하십시오. #삼. 이 문제를 해결하기 위해 다른 설정을 시도 할 때 브라우저 캐싱에 대해 조심해야합니다. 문제를 해결 한 후에도 브라우저에 "빈"이미지가 계속 표시 될 수 있습니다. # 4. 이 질문의 일부로 환경 구성 파일을 포함 시키십시오. – cailinanne

+0

안녕하세요, 코멘트 주셔서 감사합니다. 나는 더 많은 것을 포함시키기 위해 나의 질문을 편집했다. 캐시 별난이나 다른 것이 없습니다. 그냥 작동하지 않는 것 같습니다. – YavorIvanov

답변

4

2.3.3 Making Inline Attachments 섹션에 따르면, 귀하의 경우 그래서

attachments.inline['image.jpg'] = File.read('/path/to/image.jpg') 

을 다음과 같이 할 것입니다 인라인 첨부 파일을 생성하기 위해서는

attachments.inline['header.jpg'] = File.read("#{Rails.root}/app/assets/images/emails/header-general.png" 
1

설정 config.action_controller.asset_host 및 구성해야 .action_mailer.asset_host 그리고 이것은 잘 작동합니다.

config.action_mailer.asset_host = URL from where pick image 
<%= image_tag image_path('logo.png') %> 
관련 문제