Best auto complete/suggest for a search form in rails 3

autocomplete, full-text-search, ruby-on-rails-3, sphinx, thinking-sphinx

Solution

jqueryui is a great resource.

here is a demo of autocomplete, you can view the source to see how to implement on your server. http://jqueryui.com/demos/autocomplete/

the javascript sends a term=TERM to your controller. Mine is setup like this:

def autocomplete
  @movies= Movie.select("id, title").where("title LIKE ?", "#{params[:term]}%").limit(20)
  @hash = []
  @movies.each do |movie|
    @hash << {"label" => movie.title, "id" => movie.id}
  end
  render :json => @hash
end

customize to how you see fit.

Problem

I have a rails app that uses the following, - rails 3.1, - ruby 1.9.2, - mysql, - sphinx search, - will paginate, - thinking sphinx, - I opted not to use a gem for a simple login, so no devise, no authlogic. Login from scratch, using BCrypt for encrypting passwords. - JQuery. Now, this app does nothing but handles a products catalog. When I say products catalog, not just a simple one. It handles, all the features, categories, brands. There is a master text search functionality on all the product titles and features listed in 2 mysql tables. TITLES and FEATURES. Search is working fine and relevant. We have decided to include auto-complete/auto-suggest in to our app. Questions: Should I use a gem or build it from scratch?. please give your reason If I should use a gem, which one to use, does that gem is up to date and has a forum to support anytime?. We think, auto-complete/suggest on "titles" table would be fine when compared to adding auto-complete/suggest on both "titles" and "features" tables. Your comments on that? What is it, auto-suggest or auto-complete? (Like, there is PAT ALLAN and BARRY HUNTER for thinking sphinx and sphinx search,Gosh! its their dedication to support that make users sleep sound) I stated the elements of my app in detail, please advice me ! Thanks!

Original source