collectiveidea / delayed_job_active_record

ActiveRecord backend integration for DelayedJob 3.0+
MIT License
346 stars 336 forks source link

Can't create Delayed::Job record after `errors.add` in model #208

Closed kntmrkm closed 1 year ago

kntmrkm commented 1 year ago

Hi, thanks for great gem.

Can't create Delayed::Job record aftererrors.addin model

you can reproduce this repository https://github.com/kntmrkm/rails_delayed_job

if without below code errors.add(:base, 'error') . Delayed::Job record will create correctly.

https://github.com/kntmrkm/rails_delayed_job/blob/caeb7a7cb0b26630f7019f3a9cef15ac27aa263d/app/models/book.rb#L7

albus522 commented 1 year ago

This is the intended behavior. DJ loads a clean model copy from the database when running the job. It does not work with any instance state from where the job is queued.