Damien,
debugging these types of things can be tricky, but knowing what to
look at can help.
auto complete breaks into a number if steps.
1. you enter the characters into the field
2. javascript functions on the page make an ajax request to the
controller
3. the controller method accesses the model to do the search, formats
the information and renders it back to the autocomplete list div
4. steps 2 and 3 repeat until you press enter.
5. Pressing enter triggers javascript to either update the web page
locally, and/or make an ajax call to another controller method.
6. The controller method can then update whatever other part of the
page it needs to.
I am sure you have already know the above, but spelling it out helps
to debug the various stages.
You will get valuable help from Firefox-Firebug extension and the
development log. Inspecting these will show you where the process is
failing. I normally do the following, not necessarily in the same
order.
1. Look at the log to see if a call to the controller auto_complete
_for method has been made. If not, then the javascript stuff on the
page is not working. If it has, then has rails thrown an error.
2. Look at the request and response in Firebug to see if the update
information is getting back to the page.
3. Use the firebug inspector to look at the javascript that rails has
generated and see that the url etc makes sense. You dont need to be a
js guru to see roughly what is going on.
4. If you cannot make sense of 3, or need more detail, look at the
scriptacutulous info on autocompleter.
5. The bit I find hardest to get at is the controller method that is
automatically created, but it is possible to write your own controller
method to handle the auto complete, and if you use a render :update
here, you can do things like use an Alert box to show info in the
browser. I often cut and paste the source of the auto complete for
method so that I have something concrete in my controller to look at
and adapt.
finally, looking at the code you have given, the auto complete stuff
is straight forward. I notice you have included the javascript
defaults in the body rather than the header. It would be more normal
for that to be in the layout header. I don't see any reason why
putting it in the body wont work, but worth checking. Also, since you
are not loading the js library as standard for all pages, make sure it
has loaded correctly for this page by looking at the page source etc.
It may just be that the scriptaculous function is not getting called
for some reason.
Since there is nothing out of the ordinary in the auto complete fields
you are creating, it may be that there is a problem with the search
that auto complete for is doing that is causing a database/rails error
- you would see that in the log.
Hope this may be of help
Tonypm