Skip to content

Working with the paranoia gem (soft delete)

prashantjois edited this page Sep 2, 2016 · 1 revision

Paranoia allows you to soft-delete your objects. In order for the undelete to re-index your object, you must explicitly call update_pg_search_document after it is restored.

class Widget < ActiveRecord::Base
  acts_as_paranoid
  include PgSearch

  multisearchable against: [ :name, :description ]

  after_restore :update_pg_search_document
end