Ignore my previous posts, i have found what was preventing the delta
from working.

After some debugging it became apparent that for those erroneous
models the after_commit :index_delta callback just would not fire.

Thinking-sphinx enabled model does at least these three callbacks in
the order below:

before_save  :toggle_delta
after_commit :update_attribute_values
after_commit :index_delta

The update_attribute_values method threw the unhandled exception that
prevented the next after_commit from firing.

--- active_record/attribute_updates.rb

def update_attribute_values
  return true unless ThinkingSphinx.updates_enabled? &&
ThinkingSphinx.sphinx_running?

  config = ThinkingSphinx::Configuration.instance
  client = config.client

  self.class.sphinx_indexes.each do |index|
    attribute_pairs  = attribute_values_for_index(index)
    attribute_names  = attribute_pairs.keys
    attribute_values = attribute_pairs.values # ?:)
    # attribute_values = attribute_names.collect { |key|
attribute_pairs[key] }

    # here the exception
    client.update "#{index.core_name}", attribute_names, {
      sphinx_document_id => attribute_values
    } if self.class.search_for_id(sphinx_document_id, index.core_name)
  end

  true
end

client.update would throw:
"can't convert true into Integer" on the "is_active" => true, which is
boolean, and
"can't convert nil into Integer" on the "some_object_id" => nil, which
is integer...

I could not debug further because these are Riddle errors, and i do
not know if this is a bug or a feature.
Please help, i do not know what to think next.

---
thinking-sphinx 1.3.9
after_commit 1.0.5
riddle 1.0.7
and
sphinx 0.9.9 release

--

You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.


Reply via email to