In a Rails app Chewy gem is used to handle ElasticSearch indexing.
I have a block of code in an after_commit and I need it to be run once a new record of the RDB is indexed in our NRDB. it looks like:
class User < ApplicationRecord
update_index('USER') { self }
after_commit :run_this_block, on: :create
def run_this_block
index = UsersIndex.find id
'do something with index'
end
end
seems the after_commit is called before update_index!!!
Nothing is found in chewy gem,
Anyone with any idea?
That could be a possible solution, though it doesn’t work in my specific case:
There is
leavemethod inatomicstrategy of Chewy which let bypass the main atomic update_index action:It is possible to
prependleavemethod inchewy.rb: