views:

544

answers:

1

I'm trying to get Thinking Sphinx running on my site but I'm not sure how to set up the search box and button for the index page. I have in my model:

 define_index do
   indexes :name
   indexes description
   where "approved = 'true'"
 end

In my controller:

def index
  @businesses = Business.search params[:search]
end

And in my index.html.erb I installed the autocomplete plugin and have:

<h3>Search Business</h3><%= text_field_with_auto_complete :name %>

I just don't know how to link up my text box with Sphinx. Do I need to create a button? Thanks for any help.

+3  A: 

Ryan Bates has a Railscast on Thinking Sphinx that should set you in the right direction. You can view the source code for the form in Ryan's example:

<p>
  <%= text_field_tag :search, params[:search] %>
  <%= submit_tag "Search", :name => nil %>
</p>
John Topley
Already watched it. He never shows his code on his index page.
Mike
I've edited my answer to include this.
John Topley
Thanks, I didn't know all the code was contained on github. After referencing that it helped, but my code still didn't work. I had to run thinking_sphinx:rebuild.
Mike