【问题标题】:Rails mailer ignores attachment when using deliver_later with sidekiqRails 邮件程序在将 Deliver_later 与 sidekiq 一起使用时忽略附件
【发布时间】:2015-08-02 19:03:17
【问题描述】:

什么有效

我当前的 user_controller.rb 代码:

def create
  u = User.new(create_user_params)
  .
  .
  .
  if u.save
    WelcomeMailer.new_customer(u).deliver_now
    render json: u.as_json(except: [:password_digest]), status: 201
  else
    respond_with u
  end
end

我的 Mailer 的代码是:

def new_customer(user:)
  @user = user
  attachments["AGB.pdf"] = File.read("#{Rails.root}/app/assets/files/AGB.pdf")
  mail to: @user.email, subject: "blaa blubb"
end

它的工作就像一个魅力。

电子邮件带有附件。

问题:

如果我改变了

WelcomeMailer.new_customer(u).deliver_now

WelcomeMailer.new_customer(u).deliver_later

我收到了邮件,但没有附件。

我使用 sidekiq 作为作业队列(config/application.rb):

config.active_job.queue_adapter = :sidekiq

【问题讨论】:

  • 现在我尝试使用before_action :add_attachment。但也没有用过……

标签: ruby-on-rails-4 actionmailer email-attachments sidekiq


【解决方案1】:

好的……

笨拙的回答:

您必须重新启动 sidekiq-queues... 几周后现在这样做了,它就像一个魅力 hittingmyself

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-15
    • 2015-03-09
    • 1970-01-01
    • 2012-02-17
    • 1970-01-01
    • 2016-06-23
    • 2021-06-17
    • 1970-01-01
    相关资源
    最近更新 更多