Skip to content

add skip_index feature #212

Closed
wants to merge 1 commit into from
+7 −1
View
8 sunspot_rails/lib/sunspot/rails/searchable.rb
@@ -434,6 +434,10 @@ def indexable?
if_passes and unless_passes
end
+ def skip_index!
+ @skip_index = true
+ end
+
private
def constraint_passes?(constraint)
@@ -459,7 +463,9 @@ def mark_for_auto_indexing_or_removal
# :if/:unless constraints pass or were not present
@marked_for_auto_indexing =
- if !new_record? && ignore_attributes = self.class.sunspot_options[:ignore_attribute_changes_of]
+ if @skip_index
+ false
+ elsif !new_record? && ignore_attributes = self.class.sunspot_options[:ignore_attribute_changes_of]
!(changed.map { |attr| attr.to_sym } - ignore_attributes).blank?
else
true
Something went wrong with that request. Please try again.