5

I'm using sunspot and acts_as_paranoid gems in ruby on rails application.

When i'm deleting a record, acts_as_paranoid gem overrides ActiveRecord behaviour not no delete it, but update deleted_at field to not-null value. And by defaults, add to all AR queries WHERE deleted_at IS NULL scipe.

I have a lot of deleted users. And in adminpanel page I need to view and search them.

The problem is that when reindexing User model, sunspot not indexing deleted users at all (adding WHERE deleted_at IS NULL scope by default).

The only chance to index it, is to manually run

User.with_deleted.solr_reindex

So, the question is: how I should change my code, that sunspot ALWAYS index deleted records in User model?

class User < ActiveRecord::Base
  searchable do
    string  :class_name do
      self.class.name
    end

    integer(:model_id) { |user| user.id }
    integer :community_ids, references: 'Community', multiple: true

   # ...
  end

  # ...
end
delphist
  • 4,409
  • 1
  • 22
  • 22

0 Answers0