Hi Ben

I just tried to get this working on my site - and yes, it didn't work 
immediately. The issue is that Thinking Sphinx only executes the query when the 
results are actually needed - and often this is in the view, not the 
controller. rescue_from only works for exceptions raised in controllers.

However, there's an easy fix - tell TS you want the results gathered straight 
away - add :populate => true to your search call. This will make sure 
exceptions are raised in the controller.

  Article.search 'pancakes', :populate => true

The one catch with this is if you're using sphinx scopes - you don't want to 
populate until your last scope (this is the whole reason for the lazy loading - 
because you can chain one search onto another, but don't want to load results 
until the final scope is added).

Cheers

-- 
Pat

On 15/04/2011, at 9:04 AM, ben wrote:

> Has anyone gotten rescue_from to work with this error?
> 
> I have
> 
>  rescue_from Riddle::OutOfBoundsError, :with => :render_410
> 
>  def render_410
>    render :nothing => true, :status => 410
>  end
> 
> in my ApplicationController and it doesn't seem to do anything. Any
> ideas?
> 
> -Ben
> 
> -- 
> 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.
> 

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