Parker Smith Software

 
 

auto_complete in rails 2

By Brian Webb

15 Dec 2008

In rails 2 the auto_complete functionality has been moved into a plugin, so to use it you will need to first install the plugin with:

1
2

script/plugin install auto_complete

Now you can use the same auto complete functionality you are used to by adding the auto_complete_for declaration to your controller. One last gotcha is the route, you will have to add it to your routes.rb. One thing that may help if you have quite a few auto complete fields is to add a wild card route like so:

1
2
3
4

map.auto_complete ':controller/:action', 
     :requirements => { :action => /auto_complete_for_\S+/ },
     :conditions => { :method => :get }
April 04, 2009 - Ian
Thanks, that's a handy trick with the route.

No Spam: 6 + 3 =