Taking the example from the Agile, the contract for
<%= text_field_with_auto_complete :user, :language %>
is that the controller responds to
auto_complete_for_user_language
and returns a UL whose LIs are the suggested completions. In the action you can do whatever you want get the list of completions. The class method auto_complete_for is just a generator, it generates a method with that name and some default code.
There are even more flexible solutions, but I guess that's enough for what you needed.
-- fxn