Skip to content

Rework enqueuing system to ensure records got deleted accordingly #75

@chaadow

Description

@chaadow

Hi,
I tried this snippet of code as suggested in the readme for enqueuing Algolia operations :

class Contact < ActiveRecord::Base
  include AlgoliaSearch

  algoliasearch enqueue: :trigger_delayed_job do
    attribute :first_name, :last_name, :email
  end

  def self.trigger_delayed_job(record, remove)
    if remove
      record.delay.remove_from_index!
    else
      record.delay.index!
    end
  end
end

My application is running rails 3.2.22 with ruby 2.2.2 and DelayedJob 4.0.6

Without delayed job, the auto_remove works perfectly fine.
However, when I try to remove the project with the enqueuing system set, I get the following error :

ArgumentError:
       job cannot be created for non-persisted record:

after further research, I found this DJ related issue : collectiveidea/delayed_job#820
Is there any workaround to this, since I want to remove my model asynchronously from Algolia only after my project has been deleted

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions