<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>Retina Technology Blog &#187; ruby on rails</title>
	<atom:link href="http://www.retina.net/tech/category/ruby-on-rails/feed" rel="self" type="application/rss+xml" />
	<link>http://www.retina.net/tech</link>
	<description>John Adams' views on emerging technologies, software engineering, and various hacks</description>
	<lastBuildDate>Fri, 16 Sep 2011 09:06:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
	<!-- podcast_generator="podPress/8.8.10.2" -->
	<copyright>2006-2007 </copyright>
	<managingEditor>jna@retina.net (John Adams)</managingEditor>
	<webMaster>jna@retina.net (John Adams)</webMaster>
	<ttl>1440</ttl>
	<image>
		<url>http://www.retina.net/tech/wp-content/plugins/podpress/images/powered_by_podpress.jpg</url>
		<title>Retina Technology Blog &#187; ruby on rails</title>
		<link>http://www.retina.net/tech</link>
		<width>144</width>
		<height>144</height>
	</image>
	<itunes:subtitle></itunes:subtitle>
	<itunes:summary>John Adams' views on emerging technologies, software engineering, and various hacks</itunes:summary>
	<itunes:keywords></itunes:keywords>
	<itunes:category text="Technology" />
	<itunes:category text="Technology">
		<itunes:category text="Tech News" />
	</itunes:category>
	<itunes:author>John Adams</itunes:author>
	<itunes:owner>
		<itunes:name>John Adams</itunes:name>
		<itunes:email>jna@retina.net</itunes:email>
	</itunes:owner>
	<itunes:block>no</itunes:block>
	<itunes:explicit>no</itunes:explicit>
	<itunes:image href="http://www.retina.net/tech/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg" />
		<item>
		<title>Unicorn Power</title>
		<link>http://www.retina.net/tech/unicorn-power.html</link>
		<comments>http://www.retina.net/tech/unicorn-power.html#comments</comments>
		<pubDate>Wed, 31 Mar 2010 01:25:51 +0000</pubDate>
		<dc:creator>John Adams</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[rubyrails]]></category>
		<category><![CDATA[software engineering]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.retina.net/tech/unicorn-power.html</guid>
		<description><![CDATA[Ben Sandofsky and I just put a new post on the Twitter Engineering blog about our transition to Unicorn. http://engineering.twitter.com/2010/03/unicorn-power.html]]></description>
			<content:encoded><![CDATA[<p>Ben Sandofsky and I just put a new post on the Twitter Engineering blog about our transition to Unicorn. </p>
<p><a href="http://engineering.twitter.com/2010/03/unicorn-power.html">http://engineering.twitter.com/2010/03/unicorn-power.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.retina.net/tech/unicorn-power.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Autocomplete in rails 2.0</title>
		<link>http://www.retina.net/tech/autocomplete-in-rails-20.html</link>
		<comments>http://www.retina.net/tech/autocomplete-in-rails-20.html#comments</comments>
		<pubDate>Thu, 20 Mar 2008 09:08:23 +0000</pubDate>
		<dc:creator>John Adams</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[rubyrails]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.retina.net/tech/autocomplete-in-rails-20.html</guid>
		<description><![CDATA[There&#8217;s been some changes in the way that Rails 2.0 processes forms and form interaction with Ajax. Here&#8217;s a quick write-up on how to use auto completion in Rails 2.0 without a database connection. In my case, I was parsing an Apache configuration file and displaying VirtualHost entries, but you can use this for just about [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s been some changes in the way that Rails 2.0 processes forms and form interaction with Ajax. Here&#8217;s a quick write-up on how to use auto completion in Rails 2.0 without a database connection.</p>
<p>In my case, I was parsing an Apache configuration file and displaying VirtualHost entries, but you can use this for just about anything (of course, models work too if you&#8217;d like to go against the DB)</p>
<p>First, install the auto complete plugin. Rails 2.0 doesn&#8217;t have autocomplete in the core anymore, so you&#8217;ll have to create your project with the usual <strong>rails myproject</strong> syntax, and then enter that directory with <strong>cd myproject</strong>.</p>
<p>Type &#8220;script/plugin install auto_complete&#8221; to install the auto complete plugin.</p>
<p>Next, we create a simple class to hold our data. You could parse a file here (say, with File.open()), or pull data from other sources in the initialize function of this class. If you&#8217;ve got a model in the database, you can use that.</p>
<p>class Apacheconf</p>
<p>@names = []</p>
<p>def names<br />
@names<br />
end</p>
<p>def initialize<br />
# replace this code later with parsing code</p>
<p>@names = Array.new<br />
@names &lt;&lt; &#8220;alpha&#8221;<br />
@names &lt;&lt; &#8220;beta&#8221;<br />
@names &lt;&lt; &#8220;gamma&#8221;<br />
@names &lt;&lt; &#8220;delta&#8221;<br />
end</p>
<p>end</p>
<p>&#8230; then we add some code and CSS to our view for the affiliate/index method in app/views/affiliate/index.rhtml</p>
<p>&lt;html&gt;</p>
<p>&lt;head&gt;</p>
<p>&lt;%= javascript_include_tag :defaults %&gt;</p>
<p>&lt;style&gt;</p>
<p>div.auto_complete {<br />
  width: 300px; <br />
  background: #fff; <br />
} </p>
<p>div.auto_complete ul { <br />
  border: 1px solid #888; <br />
  margin: 0px; <br />
  padding: 0px; <br />
  width: 100%; <br />
  list-style-type: none; <br />
} </p>
<p>div.auto_complete ul li { <br />
  margin: 0px; <br />
  padding: 3px; <br />
} </p>
<p>div.auto_complete ul li.selected { <br />
  background-color: #ffb; <br />
} </p>
<p>div.auto_complete ul strong.highlight { <br />
  color: #800; <br />
  margin: 0px; <br />
  padding: 0px; <br />
} </p>
<p>&lt;/style&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;% form_tag :action =&gt; &#8220;edit&#8221; do %&gt;<br />
&lt;p&gt;&lt;%= text_field &#8216;affiliate&#8217;, &#8216;name&#8217;, :autocomplete =&gt; &#8216;off&#8217; %&gt;&lt;/p&gt;<br />
&lt;div class=&#8221;auto_complete&#8221; id=&#8221;affiliate_name_auto_complete&#8221;&gt;&lt;/div&gt; <br />
&lt;%= auto_complete_field :affiliate_name,<br />
     :url =&gt; { :action=&gt;&#8217;autocomplete_affiliate_name&#8217; },<br />
     :tokens =&gt; &#8216;,&#8217; %&gt;<br />
    &lt;%= submit_tag %&gt;<br />
    &lt;% end %&gt;<br />
&lt;/body&gt;</p>
<p>&#8230; and then we insert a very small amount of code into the controler (in app/controllers/affiliate_controler.rb)  to handle the Ajax callback:</p>
<p>class AffiliateController &lt; ApplicationController<br />
  skip_before_filter :verify_authenticity_token, <img src='http://www.retina.net/tech/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> nly =&gt; [:autocomplete_affiliate_name]  </p>
<p>  def autocomplete_affiliate_name<br />
     # this code is called over and over again by Ajax<br />
     #<br />
     # the next line does a search through the array for terms starting with the <br />
     # specified parameters.</p>
<p>     @x = Apacheconf.new.names<br />
     @affiliates = @x.select { |v| v =~ /^#{params[:affiliate][:name]}/ }</p>
<p>     # don&#8217;t render the layout &#8211; we only want the partial to be rendered<br />
     render :layout=&gt;false <br />
  end</p>
<p>end</p>
<p> </p>
<p>The beauty of this that with the plugin installed, it takes very little work to get autocomplete working.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.retina.net/tech/autocomplete-in-rails-20.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

