如何覆盖ActiveJob以防止序列化错误?

时间:2016-02-22 13:03:24

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

我使用mongoid 5.1,设计,邮戳发送电子邮件,我覆盖了设计方法如下: -

user.rb模型文件: -

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

现在,我在Devise中获得了ActiveJob :: SerializationError :: RegistrationsController #create"错误,如何重写ActiveJob以消除此错误,因为我是rails的新手,我对覆盖源代码没有任何想法,如果有关猴子修补或源代码覆盖的正确技巧,我将不胜感激提及。谢谢,Happy Coding。

1 个答案:

答案 0 :(得分:4)

include GlobalID::Identification添加到发送给邮件程序的任何模型。 deliver_later需要id才能从数据库中再次检索模型。

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