Reputation: 31
When i delete product in product table then productIndex not update.
My Query:
Product.friendly.where(slug: params[:id]).first.destroy_fully!
Model:
class Product < ApplicationRecord
acts_as_paranoid #for soft Delete
extend FriendlyId #slug
friendly_id :name, use: :slugged
update_index('products#product') { self }
end
Chewy library:
define_type Product.includes(:brand, product_images_attachments: :blob) do field :id field :name field :name field :slug end end
GemFile
gem 'activeadmin'
gem 'acts_as_paranoid'
gem 'friendly_id', '~> 5.4.0'
gem 'chewy', git: 'https://github.com/abdullah5514/chewy.git'
gem 'active_model_serializers'
Upvotes: 0
Views: 146
Reputation: 31
I fixed that issue. This is an issue with the acts_as_paranoid
gem.
Just, I added this into your chewy initializer, i.e. config/initializers/chewy.rb:
Chewy.use_after_commit_callbacks = false
Upvotes: 1