<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Wolfmans Howlings: Having multiple text_field_with_auto_complete in the same view</title>
    <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>A programmers Blog about Ruby, Rails and a few other issues</description>
    <item>
      <title>Having multiple text_field_with_auto_complete in the same view</title>
      <description>&lt;p&gt;I ran into a problem using &lt;code&gt;text_field_with_auto_complete&lt;/code&gt; in a view
where I wanted to have many of them created by an iteration. You can
use the :index option for the &lt;code&gt;text_field&lt;/code&gt;, but it doesn't carry over to
the various divs used in the AJAX calls.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="punct"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="number"&gt;0&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;upto&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="number"&gt;10&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;legi&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt;  &lt;span class="punct"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="string"&gt;
&amp;lt;% @leg= @mission.legs.find(:first, :conditions =&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;['&lt;/span&gt;&lt;span class="string"&gt;legnum = ?&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="ident"&gt;legi&lt;/span&gt;&lt;span class="punct"&gt;])&lt;/span&gt; &lt;span class="punct"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="string"&gt;
text_field_with_auto_complete( :leg, :name, {:index =&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt; &lt;span class="ident"&gt;legi&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="symbol"&gt;:size&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="number"&gt;20&lt;/span&gt;&lt;span class="punct"&gt;})&lt;/span&gt;
&lt;span class="punct"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="keyword"&gt;end&lt;/span&gt; &lt;span class="punct"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="string"&gt;
&amp;lt;% end %&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;is what you really want to do, just as for a regular text_field.&lt;/p&gt;

&lt;p&gt;I googled around and found &lt;a href="http://dev.rubyonrails.org/ticket/5983"&gt;this bug
report&lt;/a&gt; for a fix to
&lt;code&gt;text_field_with_auto_complete&lt;/code&gt; that allows :index, as that fix does not
appear to be in the current stable release of Rails or on Edge rails, I just created a
&lt;code&gt;my_text_field_with_auto_complete&lt;/code&gt; and it worked like a charm!!&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;my_text_field_with_auto_complete&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;object&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="ident"&gt;method&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="ident"&gt;tag_options&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;{},&lt;/span&gt; &lt;span class="ident"&gt;completion_options&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;{})&lt;/span&gt;
    &lt;span class="keyword"&gt;if&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;tag_options&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:index&lt;/span&gt;&lt;span class="punct"&gt;])&lt;/span&gt;
      &lt;span class="ident"&gt;tag_name&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&lt;span class="expr"&gt;#{object}&lt;/span&gt;_&lt;span class="expr"&gt;#{tag_options[:index]}&lt;/span&gt;_&lt;span class="expr"&gt;#{method}&lt;/span&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
    &lt;span class="keyword"&gt;else&lt;/span&gt;
      &lt;span class="ident"&gt;tag_name&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&lt;span class="expr"&gt;#{object}&lt;/span&gt;_&lt;span class="expr"&gt;#{method}&lt;/span&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt;

    &lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;completion_options&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:skip_style&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt; &lt;span class="punct"&gt;?&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;:&lt;/span&gt; &lt;span class="ident"&gt;auto_complete_stylesheet&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="punct"&gt;+&lt;/span&gt;
        &lt;span class="ident"&gt;text_field&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;object&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="ident"&gt;method&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="ident"&gt;tag_options&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="punct"&gt;+&lt;/span&gt;
        &lt;span class="ident"&gt;content_tag&lt;/span&gt;&lt;span class="punct"&gt;(&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;div&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; &lt;span class="symbol"&gt;:id&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="ident"&gt;tag_name&lt;/span&gt; &lt;span class="punct"&gt;+&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;_auto_complete&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; &lt;span class="symbol"&gt;:class&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;auto_complete&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;)&lt;/span&gt; &lt;span class="punct"&gt;+&lt;/span&gt;
        &lt;span class="ident"&gt;auto_complete_field&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;tag_name&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="punct"&gt;{&lt;/span&gt; &lt;span class="symbol"&gt;:url&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;{&lt;/span&gt; &lt;span class="symbol"&gt;:action&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;auto_complete_for_&lt;span class="expr"&gt;#{object}&lt;/span&gt;_&lt;span class="expr"&gt;#{method}&lt;/span&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;}&lt;/span&gt; &lt;span class="punct"&gt;}.&lt;/span&gt;&lt;span class="ident"&gt;update&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;completion_options&lt;/span&gt;&lt;span class="punct"&gt;))&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;So I put this in app/helpers/application_helper.rb and simply use
&lt;code&gt;my_text_field_with_auto_complete&lt;/code&gt; in my views.&lt;/p&gt;

&lt;p&gt;Here is what the controller side looks like...&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;auto_complete_for_leg_name&lt;/span&gt;
    &lt;span class="ident"&gt;leg&lt;/span&gt;&lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;params&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:leg&lt;/span&gt;&lt;span class="punct"&gt;].&lt;/span&gt;&lt;span class="ident"&gt;keys&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="number"&gt;0&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt; &lt;span class="comment"&gt;# get index as its always only one at a time&lt;/span&gt;
    &lt;span class="ident"&gt;auto_complete_responder_for_name&lt;/span&gt; &lt;span class="ident"&gt;params&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:leg&lt;/span&gt;&lt;span class="punct"&gt;][&lt;/span&gt;&lt;span class="ident"&gt;leg&lt;/span&gt;&lt;span class="punct"&gt;][&lt;/span&gt;&lt;span class="symbol"&gt;:name&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="punct"&gt;...&lt;/span&gt;
&lt;span class="ident"&gt;private&lt;/span&gt;
  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;auto_complete_responder_for_name&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
    &lt;span class="ident"&gt;param&lt;/span&gt;&lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;downcase&lt;/span&gt; &lt;span class="punct"&gt;+&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;%&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
    &lt;span class="ident"&gt;find_options&lt;/span&gt;&lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;{&lt;/span&gt;
      &lt;span class="symbol"&gt;:conditions&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;[&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;LOWER(lname) LIKE ?&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="ident"&gt;param&lt;/span&gt; &lt;span class="punct"&gt;],&lt;/span&gt;
      &lt;span class="symbol"&gt;:order&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;lname ASC&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt;
      &lt;span class="symbol"&gt;:limit&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="number"&gt;6&lt;/span&gt;
    &lt;span class="punct"&gt;}&lt;/span&gt;
    &lt;span class="attribute"&gt;@names&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;Person&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;find&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="symbol"&gt;:all&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="ident"&gt;find_options&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
    &lt;span class="ident"&gt;render&lt;/span&gt; &lt;span class="symbol"&gt;:partial&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;names&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="http://technorati.com/tag/text_field_with_auto_complete+multiple" rel="tag"&gt;&lt;/a&gt;
&lt;a href="http://technorati.com/tag/text_field_with_auto_complete" rel="tag"&gt;&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 17 Oct 2006 23:45:47 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:2a0bb86c-9179-425f-9f0c-785a7eeb3a52</guid>
      <author>Jim Morris</author>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view</link>
      <category>Rails</category>
      <category>rails</category>
      <category>text_field_with_auto_complete</category>
      <trackback:ping>http://blog.wolfman.com/articles/trackback/56</trackback:ping>
    </item>
    <item>
      <title>"Having multiple text_field_with_auto_complete in the same view" by Jared</title>
      <description>&lt;p&gt;Just thought you know this has been fixed:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;a href="http://dev.rubyonrails.org/attachment/ticket/5983/add_index_support_to_text_field_with_auto_complete.diff" rel="nofollow"&gt;http://dev.rubyonrails.org/attachment/ticket/5983/add_index_support_to_text_field_with_auto_complete.diff&lt;/a&gt;&lt;/code&gt;&lt;/p&gt;</description>
      <pubDate>Fri, 07 Mar 2008 18:43:53 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:72d5d164-2aad-44e0-bd5b-700d232355ca</guid>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view#comment-205</link>
    </item>
    <item>
      <title>"Having multiple text_field_with_auto_complete in the same view" by julien</title>
      <description>&lt;p&gt;Just wanted to say thanks for this! It solved my problem completely (I had the same issue with autogenerated fields) and it works like a charm. This should replace the standard text&lt;em&gt;field&lt;/em&gt;with_autocomplete for future releases of RoR&lt;/p&gt;</description>
      <pubDate>Mon, 03 Dec 2007 18:11:30 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:f7446823-b469-41ca-b8f6-ba9c8c7cbfdd</guid>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view#comment-176</link>
    </item>
    <item>
      <title>"Having multiple text_field_with_auto_complete in the same view" by wolfmanjm</title>
      <description>&lt;p&gt;The partial I usually use is somewhat more complex as I like to include the ID. However there is a default used which looks much like what you show above, and for the purposes of this article should be sufficient.&lt;/p&gt;</description>
      <pubDate>Sun, 15 Jul 2007 22:23:55 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:7eff1003-e12e-4bff-96d9-0382e9f96052</guid>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view#comment-101</link>
    </item>
    <item>
      <title>"Having multiple text_field_with_auto_complete in the same view" by Curtis</title>
      <description>&lt;p&gt;Maybe this?&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  `&amp;lt;ul&amp;gt;`
    &amp;lt;% @names.each do|name|%&amp;gt;
    &amp;lt;li&amp;gt;&amp;lt;%= name %&amp;gt;&amp;lt;/li&amp;gt;
    &amp;lt;%end%&amp;gt;
  `&amp;lt;/ul&amp;gt;`
&lt;/code&gt;&lt;/pre&gt;</description>
      <pubDate>Sun, 15 Jul 2007 21:11:40 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:16b73dd6-73c3-4f59-9028-772f5b54bdf5</guid>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view#comment-100</link>
    </item>
    <item>
      <title>"Having multiple text_field_with_auto_complete in the same view" by Curtis</title>
      <description>&lt;p&gt;What does your partial look like?&lt;/p&gt;</description>
      <pubDate>Sun, 15 Jul 2007 21:08:57 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:832b53d5-9b84-442e-83e1-de59cba627a2</guid>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view#comment-99</link>
    </item>
    <item>
      <title>"Having multiple text_field_with_auto_complete in the same view" by wolfmanjm</title>
      <description>&lt;p&gt;The code in my article works fine, I use it. If you are having problems, then send me more information on what problems you are having, or send me your code. The email address is at the top of this page on the right.&lt;/p&gt;</description>
      <pubDate>Fri, 13 Jul 2007 09:03:59 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:b9b661a9-7a72-4146-8664-392461ea8ed9</guid>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view#comment-93</link>
    </item>
    <item>
      <title>"Having multiple text_field_with_auto_complete in the same view" by Bala</title>
      <description>&lt;p&gt;Can you find the probs on above code&lt;/p&gt;</description>
      <pubDate>Fri, 13 Jul 2007 00:34:47 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:6d6ebb31-d0f5-4845-a683-86bf72981d47</guid>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view#comment-92</link>
    </item>
    <item>
      <title>"Having multiple text_field_with_auto_complete in the same view" by Bala</title>
      <description>Controller.

&lt;p&gt;def user&lt;em&gt;auto&lt;/em&gt;complete
    name= params[:user].keys[0] # get index as its always only one at a time
    responder&lt;em&gt;auto&lt;/em&gt;complete&lt;em&gt;for&lt;/em&gt;user_name(params[:user][name][:name])
  end&lt;/p&gt;

&lt;p&gt;private
  def responder&lt;em&gt;auto&lt;/em&gt;complete&lt;em&gt;for&lt;/em&gt;user_name(value)
    param= '%' + value.downcase + '%'
    find_options= {
      :conditions =&gt; [ 'name like ?', param ], :order =&gt; 'name ASC', :limit =&gt; 60
    }&lt;br /&gt;
    @names = User.find(:all, find_options)
    render :partial =&gt; 'names'
    #render :update do |page|
      #page['user&lt;em&gt;1&lt;/em&gt;name&lt;em&gt;auto&lt;/em&gt;complete'].show
      #page['user&lt;em&gt;1&lt;/em&gt;name&lt;em&gt;auto&lt;/em&gt;complete'].replace :partial =&gt; "names"
    #end
  end&lt;/p&gt;

Application helper

&lt;p&gt;module ApplicationHelper&lt;/p&gt;

&lt;p&gt;def my&lt;em&gt;text&lt;/em&gt;field&lt;em&gt;with&lt;/em&gt;auto&lt;em&gt;complete(object, method, tag&lt;/em&gt;options = {}, completion_options = {})
    if(tag_options[:index])
      tag&lt;em&gt;name = "#{object}&lt;/em&gt;#{tag&lt;em&gt;options[:index]}&lt;/em&gt;#{method}"
    else
      tag&lt;em&gt;name = "#{object}&lt;/em&gt;#{method}"
    end
    puts "Tag Name = &gt; " + tag_name
    (completion&lt;em&gt;options[:skip&lt;/em&gt;style] ? "" : auto&lt;em&gt;complete&lt;/em&gt;stylesheet) +
        text&lt;em&gt;field(object, method, tag&lt;/em&gt;options) +
        content&lt;em&gt;tag("div", "", :id =&gt; tag&lt;/em&gt;name + "&lt;em&gt;auto&lt;/em&gt;complete", :class =&gt; "auto_complete") +
        auto&lt;em&gt;complete&lt;/em&gt;field(tag&lt;em&gt;name, { :url =&gt; { :action =&gt; "auto&lt;/em&gt;complete&lt;em&gt;for&lt;/em&gt;#{object}&lt;em&gt;#{method}" } }.update(completion&lt;/em&gt;options))
  end&lt;/p&gt;

&lt;p&gt;def auto&lt;em&gt;complete&lt;/em&gt;text&lt;em&gt;one(object, method, tag&lt;/em&gt;options = {}, completion_options = {})
    if(tag_options[:index])
      tag&lt;em&gt;name = "#{object}&lt;/em&gt;#{tag&lt;em&gt;options[:index]}&lt;/em&gt;#{method}"
    else
      tag&lt;em&gt;name = "#{object}&lt;/em&gt;#{method}"
    end
    (completion&lt;em&gt;options[:skip&lt;/em&gt;style] ? "" : auto&lt;em&gt;complete&lt;/em&gt;stylesheet) +
    text&lt;em&gt;field(object, method, tag&lt;/em&gt;options) +
    content&lt;em&gt;tag("div", "", :id =&gt; tag&lt;/em&gt;name + "&lt;em&gt;auto&lt;/em&gt;complete", :class =&gt; "auto_complete") +
    auto&lt;em&gt;complete&lt;/em&gt;field(tag&lt;em&gt;name, { :url =&gt; { :action =&gt; "user&lt;/em&gt;auto&lt;em&gt;complete" } }.update(completion&lt;/em&gt;options))
  end&lt;/p&gt;

&lt;p&gt;def auto&lt;em&gt;complete&lt;/em&gt;text&lt;em&gt;two(object, method, tag&lt;/em&gt;options = {}, completion_options = {})
    if(tag_options[:index])
      tag&lt;em&gt;name = "#{object}&lt;/em&gt;#{tag&lt;em&gt;options[:index]}&lt;/em&gt;#{method}"
    else
      tag&lt;em&gt;name = "#{object}&lt;/em&gt;#{method}"
    end
    puts tag_name
    (completion&lt;em&gt;options[:skip&lt;/em&gt;style] ? "" : auto&lt;em&gt;complete&lt;/em&gt;stylesheet) +
    text&lt;em&gt;field(object, method, tag&lt;/em&gt;options) +
    content&lt;em&gt;tag("div", "", :id =&gt; tag&lt;/em&gt;name + "&lt;em&gt;auto&lt;/em&gt;complete", :class =&gt; "auto_complete") +
    auto&lt;em&gt;complete&lt;/em&gt;field(tag&lt;em&gt;name, { :url =&gt; { :action =&gt; "auto&lt;/em&gt;complete&lt;em&gt;for&lt;/em&gt;" + tag&lt;em&gt;name } }.update(completion&lt;/em&gt;options))
  end&lt;/p&gt;

&lt;p&gt;end&lt;/p&gt;

view file

&lt;p&gt;&amp;lt;% 1.upto(3) do |legi|  %&gt;
&amp;lt;%=auto&lt;em&gt;complete&lt;/em&gt;text_one( :user, :name, {:index =&gt; legi, :size =&gt; 20}) %&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
&amp;lt;% end %&gt;&lt;/p&gt;

Database design

&lt;p&gt;The database contains a table called 'Users' and the fieldname is 'name'.&lt;/p&gt;</description>
      <pubDate>Fri, 13 Jul 2007 00:34:25 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:7bcb1b2c-2e44-4b70-9593-c11fccf37db9</guid>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view#comment-91</link>
    </item>
    <item>
      <title>"Having multiple text_field_with_auto_complete in the same view" by wolfmanjm</title>
      <description>&lt;p&gt;Can you email me the details? I don't really understand what problem you are having.&lt;/p&gt;</description>
      <pubDate>Thu, 12 Jul 2007 16:31:33 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:301d7eb2-6a3c-4e0d-845b-c2315ad021b5</guid>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view#comment-90</link>
    </item>
    <item>
      <title>"Having multiple text_field_with_auto_complete in the same view" by Bala</title>
      <description>&lt;p&gt;I Tried this example i couldnt able to list the details but i can able to retrieve the datas what would be the problem? plz help me guyz,  one of the requirements to my project.&lt;/p&gt;</description>
      <pubDate>Thu, 12 Jul 2007 04:29:39 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:85028f43-9cc5-4f9e-922a-b41414f2564a</guid>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view#comment-89</link>
    </item>
    <item>
      <title>"Having multiple text_field_with_auto_complete in the same view" by arun agrawal</title>
      <description>&lt;p&gt;i need a default value in text box when i came that page. and when i just delete the value manually and type another then the auto text will apppear&lt;/p&gt;</description>
      <pubDate>Wed, 27 Jun 2007 07:15:33 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:26655b44-054d-49a9-8724-6002b3b25449</guid>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view#comment-6</link>
    </item>
    <item>
      <title>"Having multiple text_field_with_auto_complete in the same view" by arun agrawal</title>
      <description>&lt;p&gt;thanks&lt;/p&gt;</description>
      <pubDate>Wed, 27 Jun 2007 07:10:27 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:ce19b0db-4477-4f8a-9bd0-25f2cbecec74</guid>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view#comment-5</link>
    </item>
    <item>
      <title>"Having multiple text_field_with_auto_complete in the same view" by ThirtyTwo</title>
      <description>&lt;p&gt;Well done.  Thank you.&lt;/p&gt;</description>
      <pubDate>Tue, 31 Oct 2006 05:24:41 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:890ad241-15a8-4666-8e30-6daafe1a0dea</guid>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view#comment-36</link>
    </item>
    <item>
      <title>"Having multiple text_field_with_auto_complete in the same view" by wolfman</title>
      <description>&lt;p&gt;kevin- it will render the partial called &lt;code&gt;_names.rhtml&lt;/code&gt; in the relevant views directory. There is only one partial used in this case. Maybe I misunderstood your question?&lt;/p&gt;</description>
      <pubDate>Sun, 29 Oct 2006 13:08:54 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:3ff9a1eb-6c3a-40fb-96ed-501471b4d5a3</guid>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view#comment-12</link>
    </item>
    <item>
      <title>"Having multiple text_field_with_auto_complete in the same view" by kevin hutchison</title>
      <description>&lt;p&gt;Can i ask how the responder knows which partial to render? Or does it render all name partials?&lt;/p&gt;

&lt;p&gt;thanks much,h&lt;/p&gt;</description>
      <pubDate>Sun, 29 Oct 2006 11:12:06 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:4f7033f8-1e8a-42ee-a0fb-33d771235e38</guid>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view#comment-11</link>
    </item>
    <item>
      <title>"Having multiple text_field_with_auto_complete in the same view" by wolfman</title>
      <description>&lt;p&gt;Good point I'll add the controller side of the code too, as it does work.&lt;/p&gt;</description>
      <pubDate>Wed, 18 Oct 2006 09:31:17 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:47ef275b-c190-4674-a880-f576bba39bf1</guid>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view#comment-9</link>
    </item>
    <item>
      <title>"Having multiple text_field_with_auto_complete in the same view" by Kevin Olbrich</title>
      <description>&lt;p&gt;Whoops, no.  Actually it does work.&lt;/p&gt;</description>
      <pubDate>Wed, 18 Oct 2006 04:50:16 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:ce095b28-a99d-457a-8164-4e5570fbd459</guid>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view#comment-19</link>
    </item>
    <item>
      <title>"Having multiple text_field_with_auto_complete in the same view" by Kevin Olbrich</title>
      <description>&lt;p&gt;Nice work.  One problem I see.  When the parameters get serialized, you end up with something like   {"object"=&gt;{"index"=&gt;"value"}} in the params, which confuses the standard &lt;code&gt;auto_complete_for handler&lt;/code&gt;.&lt;/p&gt;</description>
      <pubDate>Wed, 18 Oct 2006 04:36:18 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:73685d68-53fc-4534-af93-07dee54115c8</guid>
      <link>http://blog.wolfman.com/articles/2006/10/17/having-multiple-text_field_with_auto_complete-in-the-same-view#comment-18</link>
    </item>
  </channel>
</rss>
