<?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/"
	>

<channel>
	<title>Light Year Blog &#187; Ruby &amp; Rails</title>
	<atom:link href="http://lightyearsoftware.com/blog/category/coding/ruby-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://lightyearsoftware.com/blog</link>
	<description>Thoughts on Rails, iPhone and software consulting from a Columbus indie developer.</description>
	<lastBuildDate>Fri, 03 Sep 2010 14:17:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Ruby, Threads and RubyCocoa</title>
		<link>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2010%2F05%2Fruby-threads-and-rubycocoa%2F&amp;seed_title=Ruby%2C+Threads+and+RubyCocoa</link>
		<comments>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2010%2F05%2Fruby-threads-and-rubycocoa%2F&amp;seed_title=Ruby%2C+Threads+and+RubyCocoa#comments</comments>
		<pubDate>Mon, 24 May 2010 19:43:50 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Ruby & Rails]]></category>

		<guid isPermaLink="false">http://lightyearsoftware.com/blog/?p=255</guid>
		<description><![CDATA[If you&#8217;re a Rails developer working on Mac OS X 10.6, you may have seen this message: Ruby threads cannot be used in RubyCocoa without patches to the Ruby interpreter It is caused by a plug-in or gem requiring osx/cocoa, frequently attachment_fu. AttachmentFu can use CoreImage as an image processor instead of calling out to [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re a Rails developer working on Mac OS X 10.6, you may have seen this message:</p>
<pre>
Ruby threads cannot be used in RubyCocoa without patches to the Ruby interpreter
</pre>
<p>It is caused by a plug-in or gem requiring <tt>osx/cocoa</tt>, frequently <a href="http://github.com/technoweenie/attachment_fu">attachment_fu</a>. AttachmentFu can use CoreImage as an image processor instead of calling out to an image manipulation library such as ImageMagick or GD2.</p>
<p>The warning is harmless, but it can be very noisy. To disable it, you can simply remove CoreImage from AttachmentFu&#8217;s list of image processors by creating a new file in <tt>config/initializers</tt>. Its contents should be this one line:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#6666ff; font-weight:bold;">Technoweenie::AttachmentFu</span>.<span style="color:#9900CC;">default_processors</span>.<span style="color:#5A0A0A; font-weight:bold;">delete</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'CoreImage'</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Image resize operations will now use one of the other image processors, which you can install from <a href="http://www.macports.org/">MacPorts</a>. I never deploy to a Mac OS X server for production, and I prefer to run as much of the same code as possible in development, so this isn&#8217;t a problem for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2010%2F05%2Fruby-threads-and-rubycocoa%2F&amp;seed_title=Ruby%2C+Threads+and+RubyCocoa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remember HTTP Password in Mobile Safari</title>
		<link>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2010%2F05%2Fremember-http-password-in-mobile-safari%2F&amp;seed_title=Remember+HTTP+Password+in+Mobile+Safari</link>
		<comments>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2010%2F05%2Fremember-http-password-in-mobile-safari%2F&amp;seed_title=Remember+HTTP+Password+in+Mobile+Safari#comments</comments>
		<pubDate>Mon, 03 May 2010 15:39:01 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Ruby & Rails]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://lightyearsoftware.com/blog/?p=250</guid>
		<description><![CDATA[In iPhone OS 3.0, Apple allowed Mobile Safari to save usernames and passwords in web forms. Unfortunately, Safari does not offer to do the same thing for HTTP Basic and Digest authentication. I&#8217;ve become fond of using HTTP authentication because it is very easy to set up, either in your Apache virtual host configuration or [...]]]></description>
			<content:encoded><![CDATA[<p>In iPhone OS 3.0, Apple allowed Mobile Safari to save usernames and passwords in web forms. Unfortunately, Safari does not offer to do the same thing for HTTP Basic and Digest authentication. I&#8217;ve become fond of using HTTP authentication because it is very easy to set up, either in your Apache virtual host configuration or within a Rails application. There are many times that a full-fledged user database is unnecessary for a simple administration back-end.</p>
<p>There is a work-around, though it does mean storing your user and password in plaintext in your device&#8217;s bookmarks. HTTP allows you to supply authentication credentials as part of the URL, in the form <tt>http://username:password@example.com/</tt>.</p>
<p>In the last few days, I&#8217;ve considered building a form-based login for one of my sites, just so I can do basic management from my iPad. I&#8217;m comfortable that since the device rarely leaves the house, and the data on this site is not sensitive, that leaving the password in plaintext in the bookmark is an acceptable trade-off.</p>
]]></content:encoded>
			<wfw:commentRss>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2010%2F05%2Fremember-http-password-in-mobile-safari%2F&amp;seed_title=Remember+HTTP+Password+in+Mobile+Safari/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use content_for to Put Markup In Its Place</title>
		<link>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2010%2F05%2Fuse-content_for-to-put-markup%2F&amp;seed_title=Use+content_for+to+Put+Markup+In+Its+Place</link>
		<comments>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2010%2F05%2Fuse-content_for-to-put-markup%2F&amp;seed_title=Use+content_for+to+Put+Markup+In+Its+Place#comments</comments>
		<pubDate>Mon, 03 May 2010 13:00:56 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Ruby & Rails]]></category>

		<guid isPermaLink="false">http://lightyearsoftware.com/blog/?p=244</guid>
		<description><![CDATA[Here is a useful trick for ensuring that you keep your partial templates well organized without sacrificing page-load times or duplicating your layouts unnecessarily. You can use content_for to capture some markup, but have it emitted into the page from somewhere else. Two places this is immediately useful: adding additional tags inside &#60;head&#62; and placing [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a useful trick for ensuring that you keep your partial templates well organized without sacrificing page-load times or duplicating your layouts unnecessarily.</p>
<p>You can use <tt>content_for</tt> to capture some markup, but have it emitted into the page from somewhere else.</p>
<p>Two places this is immediately useful: adding additional tags inside <tt>&lt;head&gt;</tt> and placing in-line Javascript near <tt>&lt;/body&gt;</tt>, while keeping the code itself right next to the DOM elements it works upon.</p>
<p><tt>content_for</tt> works by capturing whatever appears inside the block and storing it for later use. You emit whatever is stored using <tt>yield</tt>. What&#8217;s more, <tt>content_for</tt> doesn&#8217;t clobber the previous captured text if you use it more than once with the same key. </p>
<p>Say you have a fancy Javascript control that replaces a standard <tt>&lt;select&gt;</tt> element in forms. You can do this in your partials:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">&lt;select ...&gt;
  &lt;option&gt;...&lt;/option&gt;
  &lt;option&gt;...&lt;/option&gt;
  ...
&lt;/select&gt;
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#5A0A0A; font-weight:bold;">content_for</span> <span style="color:#ff3333; font-weight:bold;">:body_close</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  &lt;script type=&quot;text/javascript&quot;&gt;
    // code that does something with that &lt;select&gt;
  &lt;/script&gt;
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">&gt;</span></pre></div></div>

<p>And then in your layout, just before the <tt>&lt;/body&gt;</tt>:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span>= <span style="color:#9966CC; font-weight:bold;">yield</span> <span style="color:#ff3333; font-weight:bold;">:body_close</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>Because most browsers will run in-line Javascript upon encountering it, this would delay the execution of the code until all of the page content was loaded, making your page appear to load faster.</p>
<p>What&#8217;s more, if that fancy Javascript control also requires a CSS file, but you don&#8217;t want to require the browser to fetch it on all of the other pages that don&#8217;t need it, you can conditionally add it to <tt>&lt;head&gt;</tt> by defining another <tt>content_for</tt> key that accumulates additional markup to go there:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#5A0A0A; font-weight:bold;">content_for</span> <span style="color:#ff3333; font-weight:bold;">:head</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  <span style="color:#006600; font-weight:bold;">&lt;%</span>= <span style="color:#5A0A0A; font-weight:bold;">stylesheet_link_tag</span> <span style="color:#996600;">'fancy_control'</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>And in your layout:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">&lt;head&gt;
  ...
  <span style="color:#006600; font-weight:bold;">&lt;%</span>= <span style="color:#9966CC; font-weight:bold;">yield</span> <span style="color:#ff3333; font-weight:bold;">:head</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
&lt;/head&gt;</pre></div></div>

<p>This is also useful for keeping per-page markup like <tt>&lt;title&gt;</tt> and <tt>meta</tt> tags in the template and out of your controller.</p>
]]></content:encoded>
			<wfw:commentRss>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2010%2F05%2Fuse-content_for-to-put-markup%2F&amp;seed_title=Use+content_for+to+Put+Markup+In+Its+Place/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE + Rails Javascript Caching Gotcha</title>
		<link>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2010%2F04%2Fie-rails-javascript-caching-gotcha%2F&amp;seed_title=IE+%2B+Rails+Javascript+Caching+Gotcha</link>
		<comments>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2010%2F04%2Fie-rails-javascript-caching-gotcha%2F&amp;seed_title=IE+%2B+Rails+Javascript+Caching+Gotcha#comments</comments>
		<pubDate>Fri, 30 Apr 2010 20:02:46 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Ruby & Rails]]></category>

		<guid isPermaLink="false">http://lightyearsoftware.com/blog/?p=240</guid>
		<description><![CDATA[Rails supports a simple method of asset bundling with javascript_include_tag by way of the :cache option: &#60;%= javascript_include_tag 'first', 'second', 'third', :cache =&#62; true %&#62; There&#8217;s a gotcha hiding here that you may not find until you deploy to production and visit your site in IE. Admittedly, this is a bug, but if you happen [...]]]></description>
			<content:encoded><![CDATA[<p>Rails supports a simple method of asset bundling with <tt>javascript_include_tag</tt> by way of the <tt>:cache</tt> option:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span>= <span style="color:#5A0A0A; font-weight:bold;">javascript_include_tag</span> <span style="color:#996600;">'first'</span>, <span style="color:#996600;">'second'</span>, <span style="color:#996600;">'third'</span>, <span style="color:#ff3333; font-weight:bold;">:cache</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>There&#8217;s a gotcha hiding here that you may not find until you deploy to production and visit your site in IE.</p>
<p>Admittedly, this is a bug, but if you happen to have a <em>second</em> <tt>javascript_include_tag</tt> with the <tt>:cache</tt> argument in the same page, IE will choke on lots of the script, telling you &#8220;object doesn&#8217;t support this property or method,&#8221; among other things.</p>
<p>The problem is that Rails can&#8217;t resolve multiple tags using the same value for <tt>:cache</tt>, and it emits two <tt>&lt;script&gt;</tt> tags referencing the same Javascript file. IE gets confused by the second one (perhaps loading it twice?). Every other browser I&#8217;ve used handles it fine.</p>
<p>The solution: either don&#8217;t use <tt>:cache</tt> more than once or make sure you use explicit, unique bundle names instead of just <tt>true</tt>.</p>
]]></content:encoded>
			<wfw:commentRss>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2010%2F04%2Fie-rails-javascript-caching-gotcha%2F&amp;seed_title=IE+%2B+Rails+Javascript+Caching+Gotcha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On the Pain of Developing for Facebook</title>
		<link>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2009%2F11%2Fon-the-pain-of-developing-for-facebook%2F&amp;seed_title=On+the+Pain+of+Developing+for+Facebook</link>
		<comments>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2009%2F11%2Fon-the-pain-of-developing-for-facebook%2F&amp;seed_title=On+the+Pain+of+Developing+for+Facebook#comments</comments>
		<pubDate>Thu, 12 Nov 2009 21:52:26 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Ruby & Rails]]></category>

		<guid isPermaLink="false">http://lightyearsoftware.com/blog/?p=201</guid>
		<description><![CDATA[I&#8217;m in the last stages of building a site that integrates with Facebook. It includes a Facebook Connect component and a separate Facebook iframe application. In the hopes that some of my experience will help someone else out there, I will share some of my suffering and how I worked through it. This is a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in the last stages of building a site that integrates with Facebook. It includes a Facebook Connect component and a separate Facebook iframe application. In the hopes that some of my experience will help someone else out there, I will share some of my suffering and how I worked through it.</p>
<p>This is a Rails 2.3 application, using the Facebooker gem, version 1.0.54.</p>
<h4>Safari, iframes, and cookies.</h4>
<p>Chances are high you&#8217;ve found this page via search, and that you are desperate to find a solution to allow your Rails sessions to carry over from page #1 of your iframe application to page #2 and beyond. <a href="http://wcrawford.org/2007/08/29/revisited-facebook-safari-and-external-iframes-that-need-cookies/">Will Henderson</a> has a solution when your Rails application uses the ActiveRecord session store, but new Rails applications use the cookie store. There is no session to retrieve from the database; passing a row ID with links doesn&#8217;t help.</p>
<p>I am fortunate that my iframe application has a splash screen, with only one useful link on it, to start the &#8220;real&#8221; application. I append every <tt>fb_sig</tt> parameter from the current request to the link. Once the user clicks that link, the iframe no longer falls under Safari&#8217;s 3rd party cookie policy, and so the next page can set cookies. Because all of the <tt>fb_sig</tt> parameters are there, Facebooker gives precedence to them, recreating the Facebook session without consulting cookies (which either don&#8217;t exist or are stale).</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span>= <span style="color:#5A0A0A; font-weight:bold;">link_to</span> <span style="color:#996600;">'Start the app'</span>, params.<span style="color:#9900CC;">merge</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:app</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>Now, your app doesn&#8217;t always get these. When the application is first installed, you won&#8217;t get the <tt>fb_sig</tt> parameters. In this case, I force a redirect:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">unless</span> params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:fb_sig_ss</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  <span style="color:#5A0A0A; font-weight:bold;">redirect_to</span> <span style="color:#996600;">&quot;http://#{Facebooker.canvas_server_base}/#{Facebooker.facebooker_config['canvas_page_name']}/&quot;</span>
  <span style="color:#0000FF; font-weight:bold;">return</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>However&#8230;</p>
<h4>Facebooker&#8217;s Rack middleware trashes your params.</h4>
<p>Facebooker includes a piece of Rack middleware that automatically validates the signature on <tt>fb_sig</tt> parameters, and aborts the request if the signature isn&#8217;t valid. This works great on the initial request, but fails on the second request, with <em>exactly the same parameters</em>.</p>
<p>The culprit is near the bottom of <tt>Facebook#call</tt>, in <tt>rack/facebook.rb</tt>, where it calls <tt>convert_parameters!</tt>. This method is trying to be helpful, turning things like Unix time_t into Ruby Time instances. If you are trying to pass these parameters along in a link, <tt>Time.to_s</tt> is not a Unix time_t, and so the signature validation will fail, and you&#8217;re screwed.</p>
<p>Pre-Rails 2.3, there is no Rack middleware, and signature validation happens in another part of the Facebooker gem, which does not trash the original params. It does the same conversion, but on a copy. As near as I can tell, calling <tt>convert_parameters!</tt> is unnecessary, and commenting it out solves my problem. When Safari loads page #2, Facebooker creates its session, which can be stored in the Rails session, using the cookie store.</p>
<h4>Reconstituting a Facebook session in Flash.</h4>
<p>The bulk of this iframe application is actually written in Flash. Every Facebook application has an App ID (essentially a public key) and a secret key. The secret key must never be allowed outside your organization or people can fake API requests from your application. Embedding your secret key in a Flash SWF is therefore not an option, because a SWF can be decompiled. Facebook&#8217;s solution to this is the session secret, passed as <tt>fb_sig_ss</tt>.</p>
<p>According to Adobe&#8217;s <a href="http://facebook-actionscript-api.googlecode.com/svn/release/current/docs/index.html?package-summary.html&#038;all-classes.html">ActionScript 3.0 Client Library for Facebook</a> API reference, one can use the <tt>FacebookSessionUtil</tt> class to recreate a session using only the public key and the session secret. This is not true. I have to pass in <em>all</em> of the <tt>fb_sig</tt> parameters to Flash in order to make it work. However you start your Flash content, <tt>FlashVars</tt> must include:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span>= params.<span style="color:#9900CC;">collect</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>k,v<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#996600;">&quot;#{k}=#{v}&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> k.<span style="color:#9900CC;">starts_with</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;fb_sig&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">compact</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;&amp;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<h4>A refreshed page lags a &#8220;logged-in&#8221; state change until refreshed a second time.</h4>
<p>When a user logs out of Facebook and refreshes your Facebook Connect web site, it doesn&#8217;t reflect the user&#8217;s &#8220;logged-in&#8221; state change until another refresh. You can automate this and have the page refresh itself when necessary:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span> init_fb_connect <span style="color:#996600;">'XFBML'</span>, <span style="color:#ff3333; font-weight:bold;">:app_settings</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'{&quot;reloadIfSessionStateChanged&quot;:true}'</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  FB.ensureInit(function() {
    FB.Connect.get_status().waitUntilReady(function(status) {
      switch (status) {
        case FB.ConnectState.connected:
          $$('.fbConnectLoggedIn').invoke('show');
          $$('.fbConnectLoggedOut').invoke('hide');
          break;
        case FB.ConnectState.appNotAuthorized:
        case FB.ConnectState.userNotLoggedIn:
          $$('.fbConnectLoggedIn').invoke('hide');
          $$('.fbConnectLoggedOut').invoke('show');
          break;
      }
    });
  });
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>There are actually two parts to this trick. First, <tt>:app_settings => '{"reloadIfSessionStateChanged":true}'</tt> triggers the automatic refresh.</p>
<p>Second, if you have some common part of your layout that switches on a user&#8217;s Facebook status, this precludes your use of page caching. For an otherwise static page, this is a real sacrifice. To work around this, I include both sets of mark-up, classed with either &#8220;fbConnectLoggedIn&#8221; or &#8220;fbConnectLoggedOut&#8221;, and invoke Prototype&#8217;s <tt>show()</tt> or <tt>hide()</tt> on them as part of the Facebook Connect initialization. As long as you are careful to use XFBML tags that don&#8217;t require actual values from a Facebook session (e.g. <tt>&lt;fb:name uid="loggedinuser" ...&gt;</tt>), this works very well.</p>
]]></content:encoded>
			<wfw:commentRss>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2009%2F11%2Fon-the-pain-of-developing-for-facebook%2F&amp;seed_title=On+the+Pain+of+Developing+for+Facebook/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>New conditionally_cache Method for Fragment Caching</title>
		<link>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2009%2F10%2Fnew-conditionally_cache-method-for-fragment-caching%2F&amp;seed_title=New+conditionally_cache+Method+for+Fragment+Caching</link>
		<comments>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2009%2F10%2Fnew-conditionally_cache-method-for-fragment-caching%2F&amp;seed_title=New+conditionally_cache+Method+for+Fragment+Caching#comments</comments>
		<pubDate>Thu, 08 Oct 2009 00:48:40 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Ruby & Rails]]></category>

		<guid isPermaLink="false">http://lightyearsoftware.com/blog/?p=197</guid>
		<description><![CDATA[I just pushed a couple of updates to Banker. The boring one adds the missing &#8220;should_not&#8221; variants of the existing Shoulda macros. The more interesting one is a conditionally_cache method for fragment caching. If you use pagination to split content across pages, this might be very useful for you. Pages 2 and later are rarely [...]]]></description>
			<content:encoded><![CDATA[<p>I just pushed a couple of updates to <a href="http://github.com/lightyear/banker">Banker</a>. The boring one adds the missing &#8220;should_not&#8221; variants of the existing Shoulda macros.</p>
<p>The more interesting one is a <tt>conditionally_cache</tt> method for fragment caching. If you use pagination to split content across pages, this might be very useful for you. Pages 2 and later are rarely loaded, falling very quickly to the tiniest sliver of people that see page 1.</p>
<p><tt>conditionally_cache</tt> adds a new first argument to the regular <tt>cache</tt> method. This argument is evaluated in a boolean context. When true, control is passed to the <tt>cache</tt> method as usual, performing fragment caching. When false, though, the block is captured and output as if the caching code were not there at all.</p>
<p>So instead of having no caching on your paginated results or wrapping your <tt>cache</tt> call in an ugly <tt>if</tt> statement, instead you can do this:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span> conditionally_cache params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:page</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">blank</span>? <span style="color:#006600; font-weight:bold;">||</span> params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:page</span><span style="color:#006600; font-weight:bold;">&#93;</span> == <span style="color:#996600;">'1'</span>, <span style="color:#996600;">'page1'</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  ... usual HTML markup goes here ...
  ... this will be cached on page 1, but not elsewhere ...
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>Since pages 2+ are not cached, you need only expire the &#8216;page1&#8242; fragment, and nothing else.</p>
]]></content:encoded>
			<wfw:commentRss>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2009%2F10%2Fnew-conditionally_cache-method-for-fragment-caching%2F&amp;seed_title=New+conditionally_cache+Method+for+Fragment+Caching/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Bug with render :text =&gt; proc in Tests</title>
		<link>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2009%2F10%2Frails-bug-with-render-text-proc-in-tests%2F&amp;seed_title=Rails+Bug+with+render+%3Atext+%3D%26gt%3B+proc+in+Tests</link>
		<comments>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2009%2F10%2Frails-bug-with-render-text-proc-in-tests%2F&amp;seed_title=Rails+Bug+with+render+%3Atext+%3D%26gt%3B+proc+in+Tests#comments</comments>
		<pubDate>Wed, 07 Oct 2009 20:10:00 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Ruby & Rails]]></category>

		<guid isPermaLink="false">http://lightyearsoftware.com/blog/?p=195</guid>
		<description><![CDATA[There is a bug in the current stable release of Rails, 2.3.4, when using render :text => proc { ... }. The Proc object is never called by the test framework, which limits what you can test. For example, the following two techniques will both fail: Using assert_select or similar methods to check the content [...]]]></description>
			<content:encoded><![CDATA[<p>There is a bug in the current stable release of Rails, 2.3.4, when using <tt>render :text => proc { ... }</tt>. The <tt>Proc</tt> object is never called by the test framework, which limits what you can test. For example, the following two techniques will both fail:</p>
<ul>
<li>Using <tt>assert_select</tt> or similar methods to check the content of the response.</li>
<li>Setting expectations with a mocking framework on methods that are called within the <tt>Proc</tt> body.</li>
</ul>
<p><a href="https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2423">Lighthouse bug #2423</a> includes my reworked patch to fix this issue. A couple more people verifying the patch will help get it committed.</p>
]]></content:encoded>
			<wfw:commentRss>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2009%2F10%2Frails-bug-with-render-text-proc-in-tests%2F&amp;seed_title=Rails+Bug+with+render+%3Atext+%3D%26gt%3B+proc+in+Tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running Sweepers from a Model</title>
		<link>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2009%2F09%2Frunning-sweepers-from-a-model%2F&amp;seed_title=Running+Sweepers+from+a+Model</link>
		<comments>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2009%2F09%2Frunning-sweepers-from-a-model%2F&amp;seed_title=Running+Sweepers+from+a+Model#comments</comments>
		<pubDate>Thu, 17 Sep 2009 04:23:49 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Ruby & Rails]]></category>

		<guid isPermaLink="false">http://lightyearsoftware.com/blog/?p=176</guid>
		<description><![CDATA[Oh, the pain. Over the last 24 hours I have fought an exhausting battle with Rails and the testing environment to do a couple of seemingly simple things: Expire cached pages and fragments from outside the context of a normal HTTP request Test it. Testing, in particular, is particularly difficult because Rails does not offer [...]]]></description>
			<content:encoded><![CDATA[<p>Oh, the pain. Over the last 24 hours I have fought an exhausting battle with Rails and the testing environment to do a couple of seemingly simple things:</p>
<ol>
<li>Expire cached pages and fragments from outside the context of a normal HTTP request</li>
<li>Test it.</li>
</ol>
<p>Testing, in particular, is particularly difficult because Rails does not offer any built-in mechanism to test an application&#8217;s caching, and I&#8217;ve had problems in the past with the only plug-in that does it (<a href="http://blog.cosinux.org/pages/page-cache-test">cache_test</a>) it on Rails 2.x. I&#8217;ve released a new plug-in, called <a href="http://github.com/lightyear/banker">Banker</a>, that provides assertions and the necessary support to test caching, including Shoulda macros.</p>
<p>The first item has come up for me more than once. Complex applications often have scheduled jobs that make changes to the database. If the application does any caching, there is a good chance that these jobs will affect content that is cached. The problem is that expiring caches from outside the context of a controller + request is a pain. Here is the solution:</p>
<p>Create your sweepers as you normally would. Then, either within test code or your <tt>script/runner</tt> code:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> setup_cache_sweepers<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span>sweepers<span style="color:#006600; font-weight:bold;">&#41;</span>
  sweepers = sweepers.<span style="color:#9900CC;">flatten</span>
&nbsp;
  <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>.<span style="color:#9900CC;">observers</span> = sweepers
  <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>.<span style="color:#9900CC;">instantiate_observers</span>
&nbsp;
  returning <span style="color:#6666ff; font-weight:bold;">ActionController::Base</span>.<span style="color:#5A0A0A; font-weight:bold;">new</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>controller<span style="color:#006600; font-weight:bold;">|</span>
    controller.<span style="color:#9900CC;">request</span> = <span style="color:#6666ff; font-weight:bold;">ActionController::TestRequest</span>.<span style="color:#5A0A0A; font-weight:bold;">new</span>
    controller.<span style="color:#9900CC;">request</span>.<span style="color:#9900CC;">host</span> = URL_HOST
    controller.<span style="color:#9900CC;">instance_eval</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      <span style="color:#0066ff; font-weight:bold;">@url</span> = <span style="color:#6666ff; font-weight:bold;">ActionController::UrlRewriter</span>.<span style="color:#5A0A0A; font-weight:bold;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>request, <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    sweepers.<span style="color:#5A0A0A; font-weight:bold;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>sweeper<span style="color:#006600; font-weight:bold;">|</span>
      sweeper.<span style="color:#9900CC;">instance</span>.<span style="color:#9900CC;">controller</span> = controller
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p><tt>URL_HOST</tt> is a constant, defined in each environment file, with the host:port part of a URL. It is needed in order to generate URLs, and more importantly, fragment cache keys, outside the context of an HTTP request.</p>
<p>The method returns a controller. For unit test code, hang on to it, because it gives you access to named routes:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#0066ff; font-weight:bold;">@controller</span>.<span style="color:#9900CC;">send</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:users_path</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>For code run from <tt>script/runner</tt>, nothing else is needed. You&#8217;ve already instantiated your sweepers and given them the controller instance, so anything you do to a model instance that generates a callback to the sweeper will use that controller, including calling cache expiration methods.</p>
]]></content:encoded>
			<wfw:commentRss>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2009%2F09%2Frunning-sweepers-from-a-model%2F&amp;seed_title=Running+Sweepers+from+a+Model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Manage vendor/rails with Git on a Subversion Project</title>
		<link>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2009%2F09%2Fmanage-vendorrails-with-git-on-a-subversion-project%2F&amp;seed_title=Manage+vendor%2Frails+with+Git+on+a+Subversion+Project</link>
		<comments>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2009%2F09%2Fmanage-vendorrails-with-git-on-a-subversion-project%2F&amp;seed_title=Manage+vendor%2Frails+with+Git+on+a+Subversion+Project#comments</comments>
		<pubDate>Wed, 02 Sep 2009 13:52:01 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Ruby & Rails]]></category>

		<guid isPermaLink="false">http://lightyearsoftware.com/blog/?p=162</guid>
		<description><![CDATA[Here is something I&#8217;ve been experimenting with over the last week or so, and it&#8217;s working out very nicely so far: Use Git to manage vendor/rails when your project is using Subversion. Here&#8217;s how: First time freezing? Easy: cd vendor git clone git://github.com/rails/rails.git svn add -N rails; svn ps svn:ignore .git rails cd rails; git [...]]]></description>
			<content:encoded><![CDATA[<p>Here is something I&#8217;ve been experimenting with over the last week or so, and it&#8217;s working out very nicely so far:</p>
<p>Use Git to manage <tt>vendor/rails</tt> when your project is using Subversion.</p>
<p>Here&#8217;s how:</p>
<p>First time freezing? Easy:</p>
<ol>
<li><tt>cd vendor</tt></li>
<li><tt>git clone git://github.com/rails/rails.git</tt></li>
<li><tt>svn add -N rails; svn ps svn:ignore .git rails</tt></li>
<li><tt>cd rails; git checkout v2.3.3.1</tt> (or whatever version you want)</li>
<li><tt>svn add *</tt></li>
</ol>
<p>Switching to a different version of Rails is now as simple as:</p>
<ol>
<li><tt>cd vendor/rails</tt></li>
<li><tt>git checkout master</tt></li>
<li><tt>git pull origin master</tt></li>
<li><tt>git checkout <em>whatever</em></tt></li>
<li><tt>svn add `svn st | grep ^\? | cut -f7 -d" "`</tt></li>
<li><tt>svn rm `svn st | grep ^\! | cut -f7 -d" "`</tt></li>
<li><tt>svn commit</tt></li>
</ol>
<p>If you already have a <tt>vendor/rails</tt> and you want to try this technique out, you should first clone the Git repository to a temporary directory, <tt>git checkout</tt> the version that matches what is already in your <tt>vendor/rails</tt>, then copy (or move) the <tt>.git</tt> directory into <tt>vendor/rails</tt>. Add the <tt>svn:ignore</tt> property as above and you&#8217;re all set.</p>
<p>Here&#8217;s why I&#8217;m doing this: when a new Rails release comes out, some files are changed, some added and others deleted. Because Subversion litters a checked-out project with its <tt>.svn</tt> directories, you can&#8217;t just delete the entire thing and re-freeze without losing local patches (yes, I&#8217;ve had to do this) and history (which isn&#8217;t terribly important, but can be nice). Even ignoring those two reasons, completely deleting and adding <tt>vendor/rails</tt> will cause your Subversion repository to grow more than necessary (Rails 2.3.3 checks in at 35 MB).</p>
<p>Git, by putting everything in a top-level <tt>.git</tt> directory, makes itself easy for Subversion to ignore. Checking out a tag to switch to a different release is simple, and Git deletes files, unlike applying a patch, which truncates deleted files to 0 bytes, requiring a <tt>find</tt> to actually remove them.</p>
]]></content:encoded>
			<wfw:commentRss>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2009%2F09%2Fmanage-vendorrails-with-git-on-a-subversion-project%2F&amp;seed_title=Manage+vendor%2Frails+with+Git+on+a+Subversion+Project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updating RubyGems to Recent 1.3.x</title>
		<link>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2009%2F07%2Fupdating-rubygems-to-recent-1-3-x%2F&amp;seed_title=Updating+RubyGems+to+Recent+1.3.x</link>
		<comments>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2009%2F07%2Fupdating-rubygems-to-recent-1-3-x%2F&amp;seed_title=Updating+RubyGems+to+Recent+1.3.x#comments</comments>
		<pubDate>Wed, 29 Jul 2009 19:58:37 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Ruby & Rails]]></category>

		<guid isPermaLink="false">http://lightyearsoftware.com/blog/?p=140</guid>
		<description><![CDATA[The RubyGems update process can be temperamental. If you fall more than a release or two behind, you might find yourself in a dependency cycle that stops an update cold. Recently, I tried to update a 1.2.0 install to the current 1.3.5. # gem update --system Updating RubyGems Updating rubygems-update Successfully installed rubygems-update-1.3.5 ERROR: While [...]]]></description>
			<content:encoded><![CDATA[<p>The RubyGems update process can be temperamental. If you fall more than a release or two behind, you might find yourself in a dependency cycle that stops an update cold. Recently, I tried to update a 1.2.0 install to the current 1.3.5.</p>
<pre># gem update --system
Updating RubyGems
Updating rubygems-update
Successfully installed rubygems-update-1.3.5
ERROR:  While executing gem ... (NameError)
    undefined local variable or method `remote_gemspecs' for
#&lt;Gem::Commands::UpdateCommand:0xb7e26640&gt;</pre>
<p>This is a known issue. Running the command again results in &#8220;nothing to update,&#8221; also a known issue. The fix is to separately install rubygems-update and run <tt>update_rubygems</tt>.</p>
<pre># gem install rubygems-update
Successfully installed rubygems-update-1.3.5
1 gem installed
Installing ri documentation for rubygems-update-1.3.5...
Installing RDoc documentation for rubygems-update-1.3.5...
Could not find main page README
Could not find main page README
Could not find main page README
Could not find main page README
# update_rubygems
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:578:in `report_activate_error':
Could not find RubyGem builder (>= 0) (Gem::LoadError)
	from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:134:in `activate'
	from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:158:in `activate'
	from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:157:in `each'
	from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:157:in `activate'
	from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:49:in `gem'
	from /usr/bin/update_rubygems:18</pre>
<p>To fix this &#8220;report_activate_error&#8221;, I installed builder. Tried the update again, same thing for session and hoe-seattlerb. This is where I found myself in a dependency cycle.</p>
<p>rubygems-update 1.3.5 requires (among other things) hoe-seattlerb<br />
hoe-seattlerb requires hoe >= 2.3.0<br />
hoe >= 2.3.0 requires rubygems >= 1.3.1</p>
<p>I might have the specific dependency chain a bit off, but it&#8217;s enough to say that something required by rubygems-update itself requires a semi-recent RubyGems.</p>
<p>The solution is to update in stages. First update to 1.3.0, then update the rest of the way:</p>
<pre># gem install rubygems-update -v 1.3.0
Successfully installed rubygems-update-1.3.0
1 gem installed
# update_rubygems
Installing RubyGems 1.3.1
...
# gem update --system
Updating RubyGems
Updating rubygems-update
Successfully installed rubygems-update-1.3.5
:0:Warning: Gem::SourceIndex#search support for String patterns is deprecated
Updating RubyGems to 1.3.5
Installing RubyGems 1.3.5
RubyGems 1.3.5 installed</pre>
]]></content:encoded>
			<wfw:commentRss>http://lightyearsoftware.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Flightyearsoftware.com%2Fblog%2F2009%2F07%2Fupdating-rubygems-to-recent-1-3-x%2F&amp;seed_title=Updating+RubyGems+to+Recent+1.3.x/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
