text_field_with_auto_complete in a component?

Maybe this one is just way too esoteric to matter all that much, but it's bugging me. I'm doing a prototype for demonstration on Thursday, and making heavy use of components (scalability/performance not a concern, but rapid development of small contained pieces is). Here's my problem - it looks like a text_field_with_auto_complete doesn't work in a component, because of the changing controller.

I've got main/index.rhtml, from which I render component/index.rhtml.

In component/index.rhtml I have a text_field_with_auto_complete :person, :name

When it runs, however, I get an error because Rails looks for the auto_complete_for_person_name method on the *main* controller, rather than the *component* controller. I mean, I can see why it does that, I'm just trying to figure out a way around it. Best I can tell there's no :controller=>"component" option I can slap on the text field.

The strange thing is that if I do an Ajax update on the component/index.rhtml page (sort of "portlet" style where just the div updates), then the text_field_with_auto_complete works fine. So something about the Ajax update changes the context under which the text field is rendering, so that it knows it is now in the component/ controller instead of main/.

Anybody got any suggestions?

Pass :url in the rightmost options parameter:

   def text_field_with_auto_complete(object, method, tag_options = {}, completion_options = {})

like this:

   <%= text_field_with_auto_complete :user, :name, {}, :url => { ... } %>

That's a regular :url option, you may assign a named route as well for example.

-- fxn