beck03076
beck03076

Reputation: 3308

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

I have a rails app that uses the following,

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:


  1. Should I use a gem or build it from scratch?. please give your reason

  2. If I should use a gem, which one to use, does that gem is up to date and has a forum to support anytime?.

  3. 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?

  4. 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!

Upvotes: 3

Views: 3141

Answers (1)

Mike
Mike

Reputation: 1684

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.

Upvotes: 5

Related Questions