gpt4 book ai didi

nginx - Ruby On Rails : Mailer : Sidekiq - asset path not valid in email : Engineyard : Nginx : Passenger

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

我用过Sidekiq用于异步处理电子邮件。它在开发环境中运行良好,但它不会在发布的电子邮件中呈现有效的 Assets URL。

预期 Assets 网址:http://myapp.com/assets/logo-277121cb27cd5798ea5786fa2996c82f.png
拿到:http://myapp.com/images/logo.png
我正在使用 Engineyard作为 VPC。在生产/登台服务器中,我有一个名为 redis 的专用实用程序实例。其中包括redis serversidekiq正在运行的实例。他们正在正确处理电子邮件,所以我猜他们状况良好。
/data/nginx/servers/my_app.conf 中的 nginx 配置cat /data/nginx/servers/my_app.conf

server {

listen 81;

server_name _;


client_max_body_size 100M;

root /data/my_app/current/public;

access_log /var/log/engineyard/nginx/my_app.access.log main;
error_log /var/log/engineyard/nginx/my_app.error.log notice;

location ~ ^/(images|assets|javascripts|stylesheets)/ {
expires 10y;
try_files $uri $uri/index.html /last_assets/$uri /last_assets/$uri.html @app_my_app;
}

error_page 404 /404.html;
error_page 500 502 504 /500.html;
error_page 503 @503;
recursive_error_pages on;
location @503 {

error_page 405 = /system/maintenance.html;

if (-f $request_filename) {
break;
}

rewrite ^(.*)$ /system/maintenance.html break;
}

location @app_my_app {

passenger_enabled on;

passenger_set_cgi_param HTTP_X_FORWARDED_FOR $proxy_add_x_forwarded_for;
passenger_set_cgi_param HTTP_X_REAL_IP $remote_addr;
passenger_set_cgi_param HTTP_HOST $http_host;
passenger_set_cgi_param HTTP_X_FORWARDED_PROTO $scheme;
passenger_set_cgi_param HTTP_X_REQUEST_START 't=$start_time';
passenger_set_cgi_param HTTP_X_QUEUE_START 't=$start_time';

passenger_set_cgi_param SERVER_PORT 80;

rack_env staging;

passenger_min_instances 2;
}

location / {
if (-f $document_root/system/maintenance.html) { return 503; }
try_files $uri $uri/index.html $uri.html @app_my_app;
}
include /etc/nginx/servers/my_app/custom.conf;
}

我使用了辅助方法来获取组织的 Logo url
  # Gets the logo URL of the Organization set by Controller/Mailer
# in instance variable @organization
# @param [Organization] organization default value is nil
# @return [String] URL for logo image
def get_logo_url(organization = nil)
if organization && organization.logo.present?
# This case works as AWS S3 is used
organization.logo_url(:logo)
else
# This case not working
asset_url('logo.png')
end
end

最新发现 :
我尝试在不使用 sidekiq 的情况下从主应用程序发送电子邮件它在这种情况下有效。像 asset_url 这样的 Assets 助手, asset_path , image_path无法从 list 文件中获取经过处理的文件名。

最佳答案

我面临着同样的问题。问题是我没有在 sidekiq 服务器上编译 Assets ,所以那里没有 list 。

Capistrano 的变化来自:
task :compile_assets, roles: :app, primary: true do

到:
task :compile_assets, roles: [:app, :processor], primary: true do

在我个人的情况下修复了它。

关于nginx - Ruby On Rails : Mailer : Sidekiq - asset path not valid in email : Engineyard : Nginx : Passenger,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30778513/

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