I use the YUI auto-complete. Industrial strength, used on Yahoo, Flickr and other grade-A web properties.
Performance
In Rails, for the best performance on Auto-complete (no matter which widget you use), you should create a View in your database to your lookup information. Eg you want to use Autocomplete to enable the human to quickly search his posts by title (not by content).
Create a View:
# Rake task code for creating a view
def self.search_posts #
execute "DROP Table IF EXISTS search_posts"
execute "DROP View IF EXISTS search_posts"
execute "CREATE View search_posts AS
SELECT
p.id
, p.title
, p.user_id
FROM posts p
ORDER BY p.title
"
end
Also create an ActiveRecord model for SearchPost. It will pull from the view.
Then, in your controller:
# Return the id's and title's matching the search query
# Assumptions: current user id is in Session[:user_id]
# Auto complete query is in params[:query]
SearchPost.find_all(
:conditions => ["user_id = ? and title LIKE ?",
Session[:user_id], "%#{params[:query]}%"]
).collect{|rec| {'title' => rec.title, 'id' => rec.id}.to_json
Benefit
You want to minimize the amount of data looked up via the db for the Ajax requests that the auto-complete widget sends you.
Local Auto-complete
Another auto-complete architecture is the one that Flickr uses: download your entire db of post titles and ids to the browser and search against them locally. See http://code.flickr.com/blog/2009/03/18/building-fast-client-side-searches/