Record not reindexing using after_touch activerecord callback

we have been using the after_commit callback provided for activerecord to action a ‘touch’ to our model. This has so far worked fine for all new and updated commits for our model… however, we have introduced a delete function and for some reason, it is actioning all of our models custom methods but not the algolia ones.

on the join table;
after_commit :model_touch, on: [:create, :update, :destroy]
on the model;
after_touch :index!

works for all custom mehtods i.e.

def do_something
  p "Something"

but not for algolia attribute methods i.e.

attribute :column do

this has meant that our records in algolia are half correct… except that they still include the previously deleted records.


Indeed attribute in the algoliasearch blocks are not “real” model attribute so you don’t get all the feature from ActiveRecords.
Using a method instead of a block might fix it.

Could you share more details on your use case and your implementation? In this example, you can’t really change :column to trigger a reindex.