devise-async ignoring virtual attributes?
Closed this issue · 4 comments
Hello, given a user model like so:
class User < ActiveRecord::Base
attr_accessor :added_by
And setting the virtual attribute like so (quick example):
@user = User.create(... :added_by => User.find(2))
When devise-async is storing the job in delayed job, these virtual attributes are not being stored which then causes usermailer to break if these virtual attributes were expected. Was this intentional?
Thanks
@bhellman1 when devise-async enqueues the jobs it only stores the resource class and id. When the job runs the record is fetched back from the database and this virtual attribute you set before enqueueing is no longer available. If you want to use that in the mailer the only way I see is persisting it as well.
Thanks for the reply. How would you suggest persisting it?
I don't know all your context but I'd probably just add the added_by
column to the users table and remove the attr_accessor
from the model.
Got it, I thought perhaps you meant persisting the virtual attribs in some way. Thanks for the reply.