Heya Emil

I've just added those two bits of code into TS proper
http://github.com/freelancing-god/thinking-sphinx/commit/299f52491a505e56489fca1e76d280ef8e42172b

Thanks

--  
Pat

On 29/10/2008, at 5:26 PM, Emil Tin wrote:

>
> I've written a hack to make TS behave better in sitautions where the
> daemon might not be reachable. The idea is to avoid throwing
> exceptions when deleting models. Note that I'm still not handling
> updating of delta indxes (i'm not using it yet), but only deleting of
> models.
>
> It seems to work, but it's work in progress. Use at your own risk :-)
>
>
> I've added a 'thinking_sphinx_hacks' plugin in vendor/ with the
> following code:
>
>
> module ThinkingSphinx
>
>  module ActiveRecord
>    #make sure ThinkingSphinx::ConnectionError is never thrown,
>    #when destroying models, since we never want a destroy to
>    #fail just because the search index can't be updated
>
>    alias_method :original_toggle_deleted, :toggle_deleted
>
>    def toggle_deleted
>      original_toggle_deleted
>    rescue ThinkingSphinx::ConnectionError
>      #do nothing
>    end
>
>  end
>
>  class Collection < ::Array
>    #avoid throwing ActiveRecord::RecordNotFound exceptions
>    #in case a search result doesn't exists. this might
>    #otherwise happen if the search deamon could not be reached
>    #when a model was deleted, and the delete flag was not set.
>
>    class << self     #alias class methods by working on the class
> object
>
> alias_method :original_instance_from_match, :instance_from_match
>    end
>
>    def self.instance_from_match(match, options)
>      self.original_instance_from_match match, options
>    rescue ::ActiveRecord::RecordNotFound
>      #do nothing
>    end
>
>  end
>
> end
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
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