Ruby on Rails: Autocomplete with jQuery error: “Couldn’t find FileData with ID”

Just in case anyone else has this problem and does not want to bang their head against the wall for an hour like I did:

When using the autocomplete plugin that uses jQuery instead of scriptaculous, you need to add a route:

map.auto_complete ':controller/:action', 
     :requirements => { :action => /auto_complete_for_\S+/ }, 
     :conditions => { :method => :get }

As per this post by the author of the plugin, who for some unknown reason hasn’t included that step with the instructions for the plugin. (WTF?) Otherwise it just sends the request to the show action, which looks at you stupidly and replies, “Couldn’t find FileData with ID=auto_complete_for_yourfieldname”, replacing “yourfieldname” with whatever you’d actually like it to return.

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *