【问题标题】:how to override ActiveJob to prevent serialization error?如何覆盖 ActiveJob 以防止序列化错误?
【发布时间】:2016-06-03 22:15:39
【问题描述】:

我正在使用 mongoid 5.1,设计,邮戳发送电子邮件,我重写了如下设计方法:-

user.rb 模型文件:-

def send_devise_notification(notification, *args)
  devise_mailer.send(notification, self, *args).deliver_later
end  

现在,我收到“ActiveJob::SerializationError in Devise::RegistrationsController#create”错误,如何覆盖 ActiveJob 以消除此错误,因为我是 Rails 新手,所以我对覆盖没有任何想法源代码,如果提到猴子补丁或源代码覆盖的适当技术,我将不胜感激。谢谢,快乐编码。

【问题讨论】:

    标签: mongoid resque ruby-on-rails-4.2 postmark


    【解决方案1】:

    include GlobalID::Identification 添加到发送到邮件的任何模型。 deliver_later 需要一个 id 来再次从数据库中检索模型。

    http://edgeguides.rubyonrails.org/active_job_basics.html#globalid

    【讨论】:

    • 谢谢@TlmaK0,我会按照你说的实现它,如果它有效,那么将接受答案,否则我将继续在 cmets 中询问:)。再次感谢。
    • 你拯救了我的一天:)
    猜你喜欢
    • 2011-08-04
    • 1970-01-01
    • 2017-12-19
    • 2021-02-08
    • 2014-05-19
    • 2020-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多