This post originated from an RSS feed registered with Ruby Buzz
by Bob Silva.
Original Post: Extending script.aculo.us
Feed Title: Rails Video Tutorials
Feed URL: http://www.railtie.net/xml/rss/feed.xml
Feed Description: A growing collection of screencasts that show you how to use the many facets of the wonderful world of rails.
One of the great features of Rails is its plugin system. It allows you to add new functionality to the framework without modifying the original source. On my current project, I had a need to create a CachingAutoCompleter and I wanted to do it within Rails.
Rails has a method that will work just fine, text_field_with_auto_complete. The problem lies in the fact that this method creates an Ajax.Autocompleter, whereas I need an AutoComplete object with my caching functionality. I could modify the script.aculo.us source for Ajax.Autocompletor and add my caching layer but surely there's gotta be a better way, something akin to the Rails plugin system.
Click the image below to watch a screencast (7MB) of how I accomplished this goal.
You can download the source of the CachingAutoCompleter here.