ruby-on-railsrubysphinxthinking-sphinxruby-1.9.3

Sphinx Issue with Ruby 1.9.3?


I have recently moved a web app from ruby 1.8.7 to 1.9.3 and everything is going great, except for searching. Everything was working fine before bumping ruby. Here's my controller code:

ids = Business.simple_search_for_ids_with_location(@term, @city, @state, {}, :per_page => 2500)
      @results = Business.paginate :conditions => { :id => ids }, :page => ActionController::Base.helpers.sanitize(params[:page]), :include => [:category]
      @results = @results.sort{|a,b| a.name.downcase <=> b.name.downcase}
      @count = @results.total_entries

And from my model:

def self.simple_search_for_ids_with_location(term, city, state, conditions={}, options={})
  ids = Business.compact_search_for_ids(term, {:conditions => { :address_city => city, :address_state => state }.merge(conditions), :order => :business_name}.merge(options))
  if state.blank?
    by_state = Business.compact_search_for_ids(term, {:conditions => { :address_state => city }.merge(conditions), :order => :business_name}.merge(options))
    ids += by_state
  end
  ids
end

def self.compact_search_for_ids(*args)
  search_for_ids(*args).compact
end

When running in the browser I get undefined method total_entries for []:Array

And the offending line is @count = @results.total_entries

I have made sure that sphinx is installed and thinking_sphinx has indexed and is running.

It appears that everything is working somewhat, but an empty array is being returned? Why would this have worked fine before?

I appreciate any help I can get here, as I really don't want to go back to ruby 1.8.7. Thank you.


Solution

  • The solution was found through some discussion in the comments above. A couple of thoughts that may help others who come across similar issues: