Hi Pat,
I've fixed the problem, but I'm still not sure of the cause. I had
code in my controller that looped over a set of models and searched
against each one:
MODELS = [Story, Article, Course]
results = {}
MODELS.each do |model|
results[model.to_s.downcase.to_s] = model.search(params
[:query], :per_page => 10, page => 1)
end
This code threw the error I described, however, if I unroll that loop,
and just have:
results[:story] = Story.search(params[:query], :per_page => 10, page
=> 1)
results[:article] = Story.search(params[:query], :per_page => 10, page
=> 1)
results[:course] = Story.search(params[:query], :per_page => 10, page
=> 1)
Then it works fine. Is there anything obvious that I'm missing?
If I get chance today, I'll have a look at using the latest TS to
see.
Cheers!
Matt
On Jul 27, 1:55 pm, Pat Allan <[email protected]> wrote:
> sphinx_indexes is nil? Err, that is odd indeed. The variable is only
> ever assigned once (and uses ||=, so should overwrite an existing
> object), and .clear (or anything like it) is never called either.
>
> Were you using an older version of TS previously? Can you try with the
> latest (1.2.1)?
>
> --
> Pat
>
> On 23/07/2009, at 10:53 AM, Matt wrote:
>
>
>
> > Looking into this, it seems that sphinx_indexes is nil. Is there
> > anything obvious I need to check in order to fix that? Still not sure
> > as to why I'd only be getting this error on subsequent searches (the
> > rest of my app runs OK when the error occurs in TS).
>
> > Anyone any ideas?
>
> > Cheers!
>
> > Matt
>
> > On Jul 22, 12:52 pm, Matt <[email protected]> wrote:
> >> Thinking Sphinx v1.1.24
>
> >> I'm getting an error on every search I run except from the first from
> >> when my app is started. Essentially, the search works on the first
> >> request, then subsequent requests give me the following error:
>
> >> NoMethodError in SearchController#index
>
> >> You have a nil object when you didn't expect it!
> >> You might have expected an instance of Array.
> >> The error occurred while evaluating nil.last
>
> >> RAILS_ROOT: /Users/matt/Work/project
> >> Application Trace | Framework Trace | Full Trace
>
> >> /Users/matthall/Work/project/vendor/plugins/thinking-sphinx/lib/
> >> thinking_sphinx/active_record.rb:101:in `sphinx_index_options'
> >> /Users/matthall/Work/project/vendor/plugins/thinking-sphinx/lib/
> >> thinking_sphinx/search.rb:490:in `client_from_options'
> >> /Users/matthall/Work/project/vendor/plugins/thinking-sphinx/lib/
> >> thinking_sphinx/search.rb:450:in `search_results'
> >> /Users/matthall/Work/project/vendor/plugins/thinking-sphinx/lib/
> >> thinking_sphinx/search.rb:364:in `search'
> >> /Users/matthall/Work/project/vendor/plugins/thinking-sphinx/lib/
> >> thinking_sphinx/search.rb:388:in `call'
> >> /Users/matthall/Work/project/vendor/plugins/thinking-sphinx/lib/
> >> thinking_sphinx/search.rb:388:in `retry_search_on_stale_index'
> >> /Users/matthall/Work/project/vendor/plugins/thinking-sphinx/lib/
> >> thinking_sphinx/search.rb:363:in `search'
> >> /Users/matthall/Work/project/vendor/plugins/thinking-sphinx/lib/
> >> thinking_sphinx/active_record/search.rb:29:in `search'
> >> /Users/matthall/Work/project/app/controllers/search_controller.rb:
> >> 6:in
> >> `index'
> >> /Users/matthall/Work/project/app/controllers/search_controller.rb:
> >> 5:in
> >> `each'
> >> /Users/matthall/Work/project/app/controllers/search_controller.rb:
> >> 5:in
> >> `index'
> >> /Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
> >> base.rb:1322:in `send'
> >> /Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
> >> base.rb:1322:in `perform_action_without_filters'
> >> /Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
> >> filters.rb:617:in `call_filters'
> >> /Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
> >> filters.rb:610:in `perform_action_without_benchmark'
> >> /Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
> >> benchmarking.rb:68:in `perform_action_without_rescue'
> >> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/
> >> core_ext/benchmark.rb:17:in `ms'
> >> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/
> >> core_ext/benchmark.rb:10:in `realtime'
> >> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/
> >> core_ext/benchmark.rb:17:in `ms'
> >> /Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
> >> benchmarking.rb:68:in `perform_action_without_rescue'
> >> /Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
> >> rescue.rb:160:in `perform_action_without_flash'
> >> /Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
> >> flash.rb:141:in `perform_action'
> >> /Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
> >> base.rb:523:in `send'
> >> /Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
> >> base.rb:523:in `process_without_filters'
> >> /Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
> >> filters.rb:606:in `process'
> >> /Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
> >> base.rb:391:in `process'
> >> /Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
> >> base.rb:386:in `call'
> >> /Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
> >> routing/route_set.rb:433:in `call'
>
> >> Anyone seen this before?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---