Text_field_with_auto_complete with sub-attributes

So the documentation says in order to use text_field_with_auto_complete
you need to do:


Just a little test:
<%= text_field_with_auto_complete :contact, :name %>


auto_complete_for :contact, :name

In this basic example you are working with the table “contacts” and the
attribute “name” on that table.

But, when you are dealing with a more complex objects, sometimes the
attribute you care about isn’t directly an attribute of the model you
are working with. what is name is an attribute on the 7th element of an
attribute which represent a foreign key relationship off of contact?
then what?

In my case, I do something like this for a normal text field:

<%= text_field_tag "attribute[#{@attribute_index - 

1}][att_value][page_url]", @attribute.att_value.page_url %>

I have to use text_field_tag instead of text_field because I’m working
with an attribute of an attribute of an attribute of my model…

Anyway, can anybody give me some suggestions on how I could turn the
text field generated by the above code into an auto-complete field?

Also, any futher explanation on how to use “<%= field, :model, :
attribute%>”-style tags with more complicated relationships would be
really helpfull.