Can you do autocomplete on a custom data set?

I’ve been researching some of the functionality for the autocompletion
function that comes with RoR and is built around Scriptaculous.

The only question I have is if this feature can be applied to a custom
find request or can it only search through an entire table? I have a
field of names, but I’d prefer users only to be able to search through
those that also have their user_id, meaning that they created them. I
wouldn’t want them to be able to access other user’s records.

Is this even possible?

On Jun 27, 2007, at 7:30 AM, Neil H. wrote:

I’ve been researching some of the functionality for the autocompletion
function that comes with RoR and is built around Scriptaculous.

The only question I have is if this feature can be applied to a custom
find request or can it only search through an entire table?

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