Hi Pat, Thanks for the work-around, this will solve my problem.
With the search facility being a key part of my application. Instead of letting the user hit a standard error page, I prefer users to get a more informative message like: "Sorry, the search engine is temporarily unavailable." Having said that, once properly configured and running. ThinkingSphinx has been very reliable. I am just trying to cover all the bases... Many thanks, Oliver. On 12 Dec, 08:07, Pat Allan <[email protected]> wrote: > Hi Oliver > > I'm not quite sure of the best way to sort out this issue - the lazy result > loading is a key part of chaining sphinx scopes together without querying > Sphinx multiple times... but hitting errors in views instead of the > controller is definitely not ideal. > > As a work-around, if you change your controller to be the following, this > should ensure the error happens within the action instead: > > def search > @products = Product.search(params[:criteria]) > @products.first > > # ... > end > > The request for the actual results forces the query to happen in the > controller. > > Still, this is ugly code, but it's the best I've got at the moment (other > suggestions very much welcome). > > -- > Pat > > On 11/12/2009, at 11:13 PM, karmacoma wrote: > > > Hi, > > I'm looking for a bit of advice on how to handle sphinx connection > > errors > > within my application. > > > Due to some underlying changes within ThinkingSphinx I am no longer > > able > > to rescue from ThinkingSphinx::ConnectionErrors at the controller > > level. > > > Here is what I used to do, which worked quite nicely. > > > === > > class ProductsController < ApplicationController > > rescue_from ThinkingSphinx::ConnectionError, :with => :search_failed > > > # GET /products/search > > def search > > �...@products = Product.search(params[:criteria]) > > > respond_to do |format| > > format.html # search.html.erb > > end > > end > > end > > === > > > However, at the moment the ConnectionError exception is not raised > > until my application hits the view layer and calls: @products.empty? > > > So how do I handle this now? > > Ideally I would like to handle the exception as I did before. > > > The only other alternative that has come to mind, is to call > > sphinx_running? before each search query - but that seems a bit > > of an expensive call to make. > > > Any advice would be much appreciated. > > > Kind regards, Oliver. > > > -- > > > 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 > > athttp://groups.google.com/group/thinking-sphinx?hl=en. -- 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.
