<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - Problem with Rails 2.0 auto_complete plugin]]></title>
	<link rel="self" href="http://railsforum.com/extern.php?action=feed&amp;tid=13746&amp;type=atom"/>
	<updated>2008-08-16T01:49:45Z</updated>
	<generator>PunBB</generator>
	<id>http://railsforum.com/viewtopic.php?id=13746</id>
		<entry>
			<title type="html"><![CDATA[Re: Problem with Rails 2.0 auto_complete plugin]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?pid=72142#p72142"/>
			<content type="html"><![CDATA[<p>Hi Chris,</p><p>I appreciate your response. Turns out that my main issue was simply my own stupidity. <img src="http://railsforum.com/img/smilies/tongue.png" width="15" height="15" alt="tongue" /> I had a before_filter that was accidentally copied over from another controller which was interfering with my AJAX call and continuously redirecting me to my &quot;new&quot; action.</p><p>I have used jQuery previously in other non-rails projects, but as I am still quite new to rails and not at all a JS expert, I am trying to stick with Prototype/Scriptaculous at least to begin with, in the hope that this will mean less unknowns and more available documentation. </p><p>However, I am a fan of progressive enhancement and unobtrusive JS, so I have been experimenting with Dan Webb&#039;s Low Pro extension for Prototype. This means that I will most likely be preferring to do things in a little more manual way and as you say, write my own autocomplete method. I will checkout your plugin code, thanks.</p><p>I am still not sure if/how I may be able to leverage RJS functionality for AJAX stuff considering that I would prefer to do my JS/AJAX stuff unobtrusively... If you (or anyone else) have any tips or resources on this subject, I would be grateful.</p>]]></content>
			<author>
				<name><![CDATA[jonny_noog]]></name>
				<uri>http://railsforum.com/profile.php?id=15396</uri>
			</author>
			<updated>2008-08-16T01:49:45Z</updated>
			<id>http://railsforum.com/viewtopic.php?pid=72142#p72142</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Problem with Rails 2.0 auto_complete plugin]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?pid=72135#p72135"/>
			<content type="html"><![CDATA[<p>Hi, I&#039;m the author of the codeintensity blog entries you referred to.&nbsp; I can&#039;t vouch for the Prototype based versions in Rails 2.1, but I use the jQuery one, as per my blog entry in Rails 2.1.&nbsp; A couple things to mention.&nbsp; First, do you have routes in for the auto complete functions?&nbsp; I found I had to do that.&nbsp; I use something like this to handle them all in one route definition:</p><p><pre name="code" class="ruby:nogutter"># Handle all auto_complete routes:<br />map.auto_complete &#039;:controller/:action&#039;, :requirements =&gt; { :action =&gt; /auto_complete_for_\S+/ },<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:conditions =&gt; { :method =&gt; :get }</pre><br />Also, I&#039;ve switched to a newer jQuery auto-complete plugin that I&#039;m finding works a lot better for me.&nbsp; I covered this in an <a href="http://codeintensity.blogspot.com/2008/07/update-on-rails-jquery-autocomplete.html">updated blog entry</a>.</p><p>Finally, I&#039;m not sure I followed what precise problem you&#039;re having at this point.&nbsp; Are your auto-complete methods being called?&nbsp; If not, one way that&#039;s easier to debug is to not use the plugin&#039;s implementation, but just write your own.&nbsp; To get started on that, just take the definition from my plugin and plop it into your controller, and then tweak it to directly reference your controller and model names (instead of the generated stuff from the plugin).&nbsp; This is handy because then you can put in logging statements, or step through it in a debugger, or whatever will help you debug.&nbsp; </p><p>If that&#039;s still not working, please do respond and let us know precisely what fails, and I&#039;ll see if I can&#039;t help you nail it.</p>]]></content>
			<author>
				<name><![CDATA[chrisrbailey]]></name>
				<uri>http://railsforum.com/profile.php?id=11036</uri>
			</author>
			<updated>2008-08-15T23:05:52Z</updated>
			<id>http://railsforum.com/viewtopic.php?pid=72135#p72135</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Problem with Rails 2.0 auto_complete plugin]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?pid=71515#p71515"/>
			<content type="html"><![CDATA[<p>Does the auto_complete code depend on the CSS symbol &quot;div.auto_complete&quot; in its code? e.g. Is &quot;div.auto_complete&quot; a well-known symbol that ties the CSS to the auto_complete plug-in?</p><p>Jay</p><div class="quotebox"><cite>sandy wrote:</cite><blockquote><p>If you are working on a pre existing project, migrated from rails 1.2.# generate a new project and copy over those js files.&nbsp; For me, if i downloaded prototype from the website i would get client side errors with the js and thus nothing would appear.&nbsp; What i did to get everything working was this:</p><p>In your controller keep the condition:</p><p><pre name="code" class="ruby:nogutter">auto_complete_for :event, :location</pre><br />Then in the view:</p><p><pre name="code" class="ruby:nogutter">&lt;%= text_field_with_auto_complete :event, :location, {}, :skip_style =&gt; true %&gt;</pre><br />You need to include some extracted css and include it also in your project:</p><p><pre name="code" class="ruby:nogutter">div.auto_complete ul {<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;border:1px solid #888;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;margin:0;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;padding:0;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;width:100%;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;list-style-type:none;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />div.auto_complete ul li {<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;margin:0;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;padding:3px;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />div.auto_complete ul li.selected {<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;background-color: #ffb;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />div.auto_complete ul strong.highlight {<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;color: #800; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;margin:0;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;padding:0;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</pre></p></blockquote></div>]]></content>
			<author>
				<name><![CDATA[jgodse]]></name>
				<uri>http://railsforum.com/profile.php?id=15455</uri>
			</author>
			<updated>2008-08-12T04:07:10Z</updated>
			<id>http://railsforum.com/viewtopic.php?pid=71515#p71515</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Problem with Rails 2.0 auto_complete plugin]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?pid=71504#p71504"/>
			<content type="html"><![CDATA[<p>So continuing on with the investigation of my issue, I tried to use the straight Scriptaculous Ajax.Autocompleter as mentioned here: <a href="http://codeintensity.blogspot.com/2008/06/rails-jquery-auto-complete-and-new.html.">http://codeintensity.blogspot.com/2008/ &#133; -new.html.</a> And still FireBug shows me a GET request to my auto_complete_for function, then another GET request to my new action. No autocomplete.</p><p>Then I tried to swap out Prototype/Scriptaculous completely for jQuery as mentioned here: <a href="http://codeintensity.blogspot.com/2008/06/rails-jquery-auto-complete-and-new.html.">http://codeintensity.blogspot.com/2008/ &#133; -new.html.</a> The only difference being that with jQuery, it would appear that I&#039;m getting 4 GET requests instead of two. The first once again to my auto_complete_for function, the second to my new action, then repeat.</p><p>Has anyone got an AJAX autocomplete working with Rails 2.1.0, in any way at all? If so could anyone post some examples of how they did it?</p><p>I would consider giving my first born child in payment for assistance with this problem. <img src="http://railsforum.com/img/smilies/tongue.png" width="15" height="15" alt="tongue" /></p>]]></content>
			<author>
				<name><![CDATA[jonny_noog]]></name>
				<uri>http://railsforum.com/profile.php?id=15396</uri>
			</author>
			<updated>2008-08-12T02:01:35Z</updated>
			<id>http://railsforum.com/viewtopic.php?pid=71504#p71504</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Problem with Rails 2.0 auto_complete plugin]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?pid=71390#p71390"/>
			<content type="html"><![CDATA[<p>Hello,</p><p>New Rails user, just joined up here. After doing a search, this thread seems like the closest thing I can find to the issue I&#039;m having.</p><p>I&#039;m using Rails 2.1.0 and I&#039;m trying to get the auto_complete plugin to work. When I type something into the relevant text box, I don&#039;t get an error as such, but nor do I get any autocomplete suggestions.</p><p>I have downloaded/installed the plugin and I have also added the required &lt;%= javascript_include_tag :defaults %&gt; into my layout.</p><p>I have a RESTful MembersController with a new action that displays a form for a new member to use in order to sign up. Along with the MembersController, I have a Member model which has a belongs_to association with a Suburb model. This Suburb model stores the names and postcodes of suburbs. What I am wanting to achieve is to get an autocomplete field in the form displayed by the MembersController&#039;s new action that will allow a member to start typing their suburb and then the autocomplete is meant to kick in.</p><p>Looking in FireBug, I can see that when I type something into the text box, a GET request is being fired that is going to the auto_complete function and then immediately afterwards, another GET request is fired, going to my new action(?). But no suggestions appear. In both cases, the response I can see being returned in FireBug appears to be the whole new.html.erb, which doesn&#039;t seem right to me, but I don&#039;t know how to go about searching further into this issue.</p><p>I have been mainly trying to cobble together something from these two tutorials:<br /><a href="http://codeintensity.blogspot.com/2008/02/auto-complete-text-fields-in-rails-2.html">http://codeintensity.blogspot.com/2008/ &#133; ils-2.html</a> (this one talks about drawing the autocomplete data from a different model, which is what I am trying to do)<br /><a href="http://trix.pl/blog/auto-complete-for-rails-2-0-tutorial.html">http://trix.pl/blog/auto-complete-for-r &#133; orial.html</a></p><p>Here is my code:</p><p>In routes.rb I have:<br /><pre name="code" class="ruby:nogutter">map.resources :members, :collection =&gt; {:auto_complete_for_member_suburb =&gt; :get }</pre><br />I made it a GET so that the forgery protection issue does not come into play as per one of the above tutorials.</p><p>In the new.html.erb for my MembersController, I have:<br /><pre name="code" class="ruby:nogutter">&lt;%= text_field_with_auto_complete :member, :suburb, { :autocomplete =&gt; &#039;off&#039; }, { :method =&gt; :get }&nbsp; %&gt;</pre><br />In members_controller.rb, I have:<br /><pre name="code" class="ruby:nogutter">def auto_complete_for_member_suburb<br />&nbsp; &nbsp; re = Regexp.new(&quot;^#{params[:member][:suburb]}&quot;, &quot;i&quot;)<br />&nbsp; &nbsp; find_options = { :order =&gt; &quot;name ASC&quot; }<br />&nbsp; &nbsp; @suburbs = Suburb.find(:all, find_options).collect(&amp;:name).select { |s| s.match re }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; render :inline =&gt; &quot;&lt;%= content_tag(:ul, @suburbs.map { |s| content_tag(:li, h(s)) }) %&gt;&quot;<br />end</pre><br />I&#039;m trying to implement a custom auto_complete_for_member_suburb as the data for the autocomplete is coming from another model (the Suburb model) in a similar way to what was described in one of the above tutorials.</p><p>Being new to Rails, I&#039;m assuming the issue is just something stupid that I am overlooking... Possibly to do with the fact that I am trying to get the autocomplete to draw data from another model, which I understand is a little non-standard.</p><p>Sorry for the rather long first post. Any help at all would be greatly appreciated.</p><p>I would also love if anyone could recommend some good web pages or books on the subject of AJAX + Rails 2.1.0 as I am feeling a bit like a fish flopping around on the ground when it comes to using AJAX with Rails. <img src="http://railsforum.com/img/smilies/tongue.png" width="15" height="15" alt="tongue" /></p>]]></content>
			<author>
				<name><![CDATA[jonny_noog]]></name>
				<uri>http://railsforum.com/profile.php?id=15396</uri>
			</author>
			<updated>2008-08-11T06:41:12Z</updated>
			<id>http://railsforum.com/viewtopic.php?pid=71390#p71390</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Problem with Rails 2.0 auto_complete plugin]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?pid=49557#p49557"/>
			<content type="html"><![CDATA[<p>If you are working on a pre existing project, migrated from rails 1.2.# generate a new project and copy over those js files.&nbsp; For me, if i downloaded prototype from the website i would get client side errors with the js and thus nothing would appear.&nbsp; What i did to get everything working was this:</p><p>In your controller keep the condition:</p><p><pre name="code" class="ruby:nogutter">auto_complete_for :event, :location</pre><br />Then in the view:</p><p><pre name="code" class="ruby:nogutter">&lt;%= text_field_with_auto_complete :event, :location, {}, :skip_style =&gt; true %&gt;</pre><br />You need to include some extracted css and include it also in your project:</p><p><pre name="code" class="ruby:nogutter">div.auto_complete ul {<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;border:1px solid #888;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;margin:0;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;padding:0;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;width:100%;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;list-style-type:none;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />div.auto_complete ul li {<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;margin:0;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;padding:3px;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />div.auto_complete ul li.selected {<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;background-color: #ffb;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />div.auto_complete ul strong.highlight {<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;color: #800; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;margin:0;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;padding:0;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</pre></p>]]></content>
			<author>
				<name><![CDATA[sandy]]></name>
				<uri>http://railsforum.com/profile.php?id=6608</uri>
			</author>
			<updated>2008-01-04T06:03:44Z</updated>
			<id>http://railsforum.com/viewtopic.php?pid=49557#p49557</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Problem with Rails 2.0 auto_complete plugin]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?pid=49511#p49511"/>
			<content type="html"><![CDATA[<p>you can just run script/plugin install auto_complete</p><p>I am afraid it still doesn&#039;t work.&nbsp; I also added Scriptaculous.js but still nothing.</p><p>why why why....</p>]]></content>
			<author>
				<name><![CDATA[foozilla]]></name>
				<uri>http://railsforum.com/profile.php?id=4550</uri>
			</author>
			<updated>2008-01-04T00:55:27Z</updated>
			<id>http://railsforum.com/viewtopic.php?pid=49511#p49511</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Problem with Rails 2.0 auto_complete plugin]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?pid=49509#p49509"/>
			<content type="html"><![CDATA[<p>Wow, four in one.</p><p>auto_complete has been taken out of Rails and put into a plugin. You can all download it via script/plugin install auto_complete, or from here:</p><p><a href="http://svn.rubyonrails.org/rails/plugins/auto_complete/">http://svn.rubyonrails.org/rails/plugins/auto_complete/</a></p>]]></content>
			<author>
				<name><![CDATA[Radar]]></name>
				<uri>http://railsforum.com/profile.php?id=174</uri>
			</author>
			<updated>2008-01-04T00:38:36Z</updated>
			<id>http://railsforum.com/viewtopic.php?pid=49509#p49509</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Problem with Rails 2.0 auto_complete plugin]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?pid=49505#p49505"/>
			<content type="html"><![CDATA[<p>I am having same problem too..what is the solution? Anyone?</p>]]></content>
			<author>
				<name><![CDATA[rambo]]></name>
				<uri>http://railsforum.com/profile.php?id=7702</uri>
			</author>
			<updated>2008-01-04T00:15:57Z</updated>
			<id>http://railsforum.com/viewtopic.php?pid=49505#p49505</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Problem with Rails 2.0 auto_complete plugin]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?pid=49500#p49500"/>
			<content type="html"><![CDATA[<p>I am having same problem.</p><p>I just downloaded the plugin for auto_complete but nothing.<br />I also realized that Scriptaculous.js was not there.&nbsp; </p><p>Is that right that ScriptaculousHelper is not added to 2.0?&nbsp; What the hack?</p>]]></content>
			<author>
				<name><![CDATA[foozilla]]></name>
				<uri>http://railsforum.com/profile.php?id=4550</uri>
			</author>
			<updated>2008-01-03T23:47:01Z</updated>
			<id>http://railsforum.com/viewtopic.php?pid=49500#p49500</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Problem with Rails 2.0 auto_complete plugin]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?pid=48238#p48238"/>
			<content type="html"><![CDATA[<p>got the exact same problem :S nothing happens and nothing shows up in firebug either</p>]]></content>
			<author>
				<name><![CDATA[henryb]]></name>
				<uri>http://railsforum.com/profile.php?id=7915</uri>
			</author>
			<updated>2007-12-18T21:06:04Z</updated>
			<id>http://railsforum.com/viewtopic.php?pid=48238#p48238</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Problem with Rails 2.0 auto_complete plugin]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?pid=47945#p47945"/>
			<content type="html"><![CDATA[<p>I am having problems with the Rails 2.0 auto_complete plugin. Unlike other reported errors I don&#039;t get any errors at all - in fact nothing happens.&nbsp; I&#039;ve made sure that everything is in its right place in the controller and views and have also downloaded the latest files from scriptaculous. (By the way auto_complete worked fine in Rails 1.2.5 before the plugin was required)</p><p>Would appreciate any advice.<br />Thanks</p>]]></content>
			<author>
				<name><![CDATA[archie]]></name>
				<uri>http://railsforum.com/profile.php?id=8392</uri>
			</author>
			<updated>2007-12-16T13:52:12Z</updated>
			<id>http://railsforum.com/viewtopic.php?pid=47945#p47945</id>
		</entry>
</feed>
