As discussed in #1173 and initially prompted by discussions in #1158, this commit removes the automatic insertion of callbacks into every single ActiveRecord model, and instead expects them to be explicitly added to the models that are indexed. The syntax is as follows:
Given this code will almost always be invoked from within an ActiveRecord model, the model argument will be self.
The reference is optional, but should match the first argument of the index in question. e.g. it’ll likely be the model name, lowercase and underscored, as a symbol. If the model is namespaced, though, this should be a string, with slashes to indicate the namespacing (like how a namespaced index is defined).
The options are behaviour and path. Behaviour is an array of symbols, which include the following:
:sql for SQL-backed indices.
:real_time for real-time indices.
:deltas if the SQL-backed indices have deltas enabled.
:updates if attribute_updates is configured to true (which is probably not the case for many people). This is only for SQL-backed indices.
Both the path option and the block argument are the same as what would have been passed into ThinkingSphinx::RealTime.callback_for, and have no impact for SQL-backed callbacks. This new approach replaces the need for ThinkingSphinx::RealTime.callback_for (but it continues to work for now).
As discussed in #1173 and initially prompted by discussions in #1158, this commit removes the automatic insertion of callbacks into every single ActiveRecord model, and instead expects them to be explicitly added to the models that are indexed. The syntax is as follows:
Given this code will almost always be invoked from within an ActiveRecord model, the
model
argument will beself
.The
reference
is optional, but should match the first argument of the index in question. e.g. it’ll likely be the model name, lowercase and underscored, as a symbol. If the model is namespaced, though, this should be a string, with slashes to indicate the namespacing (like how a namespaced index is defined).The options are
behaviour
andpath
. Behaviour is an array of symbols, which include the following::sql
for SQL-backed indices.:real_time
for real-time indices.:deltas
if the SQL-backed indices have deltas enabled.:updates
ifattribute_updates
is configured to true (which is probably not the case for many people). This is only for SQL-backed indices.Both the path option and the block argument are the same as what would have been passed into
ThinkingSphinx::RealTime.callback_for
, and have no impact for SQL-backed callbacks. This new approach replaces the need forThinkingSphinx::RealTime.callback_for
(but it continues to work for now).