I’m trying to set up Thinking Sphinx in my Rails 3 app, but I am getting a “Routing Error”.
I set up MySQL and installed Sphinx without error. My gemfile contains:
gem "riddle", "~> 1.5.0"
gem "thinking-sphinx", "~> 2.0.10"
These install without a problem.
My model contains:
define_index do
indexes :name
indexes acad_field
indexes expertise
indexes interests
indexes experience
indexes marital_status
indexes email
indexes place_of_birth
indexes birthyear
indexes hometown
indexes current_residence
indexes languages
indexes nationalities
indexes ethnicities_mom_dad
indexes institution
indexes program
end
and my index action in my controller contains:
def index
@profiles = Profile.search params[:search]
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @profiles }
end
end
This is what my routes look like:
match "profiles?search=:search", :to => "profiles#index"
When I try running a search by typing the search criteria URL directly into the browser, I get this error:
Routing Error
undefined method `define_index' for #<Class:0xb3ada670>
What do I need to do?
Running
rake thinking_sphinx:rebuildfixed my “undefined method” problem.