Wow, quick reply!  Thanks James.

The problem with using an ApplicationController-based approach is that
in different cases I want to do different things when I can't connect
to Sphinx, for example, if I can't query items from Sphinx, I can
still go grab them from the DB directly in less efficient ways.  Thus,
in these cases, it's useful for me to be able to rescue the exceptions
where they happen, on a case-by-case basis.

Of course, if there is no way to get TS to not be lazy about
executing, I can work around with an ugly-hack approach like I listed
earlier, but the hack eats at my soul a bit.

B

On Jan 12, 7:25 pm, James Healy <[email protected]> wrote:
> wbharding wrote:
> > Pretty ugly.  Does anyone know of a better way to tell TS to actually
> > conduct the search on the line that I call it from?
>
> I'm not sure how to stop TS lazy evaluating the search, there is a neat
> way to catch sphinx connection exceptions. Add the following to your
> ApplicationController, and you won't need to wrap each search call in a
> rescue block (unless you need to display a custom error for each search).
>
>     rescue_from ThinkingSphinx::ConnectionError, :with => 
> :sphinx_connection_error
>
>     # method for handling the Sphinx daemon being unavailable. We don't
>     # want to let it filter through to the default 500 page, as it isn't
>     # a major issue, and can be easily fixed.
>     def sphinx_connection_error
>       render :template => 'errors/sphinx_connection.html.erb', :status => 500
>     end
>
> -- James Healy <[email protected]>  Wed, 13 Jan 2010 14:24:33 +1100
-- 
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