<?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>Jabbering Giraffe &#187; rails</title>
	<atom:link href="http://happygiraffe.net/blog/tag/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://happygiraffe.net/blog</link>
	<description></description>
	<lastBuildDate>Tue, 07 Feb 2012 20:49:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Skillswap: Intro to Rails</title>
		<link>http://happygiraffe.net/blog/2007/04/06/skillswap-intro-to-rails/</link>
		<comments>http://happygiraffe.net/blog/2007/04/06/skillswap-intro-to-rails/#comments</comments>
		<pubDate>Fri, 06 Apr 2007 18:00:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[brighton]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[skillswap]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2007/04/06/skillswap-intro-to-rails/</guid>
		<description><![CDATA[Last night I presented a skillswap, &#8220;Introduction to Rails&#8221;. This was meant to be a fairly quick overview for people who&#8217;ve done some web development before, but are completely new to Rails (and Ruby). The event was presented in two &#8230; <a href="http://happygiraffe.net/blog/2007/04/06/skillswap-intro-to-rails/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Last night I presented a <a href="http://www.skillswap-brighton.org/">skillswap</a>, &#8220;Introduction to Rails&#8221;.  This was meant to be a fairly quick overview for people who&#8217;ve done <em>some</em> web development before, but are completely new to Rails (and Ruby).  The event was presented in two parts.  First, a set of slides about what Rails is, why it works and a brief overview of Ruby.  Then, a practical session.</p>
<p>For the practical, I installed <a href="http://locomotive.raaum.org/">Locomotive</a> and we ran through a quick session of getting started with a rails application, building a model and putting up some scaffolding on top of that.  There were only five macs, so people had to work together, which probably helped.  I have to issue a <em>huge</em> thanks to <a href="http://www.lighthouse.org.uk/">lighthouse</a> for the opportunity to use the fantastic venue.</p>
<p>I did actually have further slides and handouts, which progressed the practical, but it was already getting on for 20:30, so it seemed wiser to halt whilst things were still going well.</p>
<p>Like all live things, not all went to plan.  The main annoyance was the fact that Locomotive-generated projects (well, Rails really) default to using <a href="http://www.mysql.com/">MySQL</a>.  A quick switch to <a href="http://www.sqlite.org/">SQLite</a> made things work a lot better.  Servers can be a pain when you&#8217;re trying to get things running.</p>
<p>The slides and handout are available for download.</p>
<ul>
<li><a href="http://happygiraffe.net/blog/files/Rails_Introduction.zip">Introduction to Rails</a> (Keynote, 1.5Mb)</li>
<li><a href="http://happygiraffe.net/blog/files/Rails_Introduction.pdf">Introduction to Rails</a> (PDF, 776Kb)</li>
<li><a href="http://happygiraffe.net/blog/files/Rails_Introduction_Handout.pdf">Introduction to Rails Handout</a> (PDF, 68Kb)</li>
<li><a href="http://happygiraffe.net/blog/files/Rails_Introduction_Handout.zip">Introduction to Rails Handout</a> (Pages, 36Kb)</li>
</ul>
<p>Also many thanks to <a href="http://jane.dallaway.com/blog/2007/04/skillswap-introduction-to-rails.html">Jane</a> for the kind words.  <img src='http://happygiraffe.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2007/04/06/skillswap-intro-to-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mongrel&#039;s Default Charset</title>
		<link>http://happygiraffe.net/blog/2006/11/18/mongrels-default-charset/</link>
		<comments>http://happygiraffe.net/blog/2006/11/18/mongrels-default-charset/#comments</comments>
		<pubDate>Sat, 18 Nov 2006 18:07:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mongrel]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2006/11/18/mongrels-default-charset/</guid>
		<description><![CDATA[I suddenly noticed that my last entry had Unicode problems. How embarrassing. It turns out that mongrel doesn&#8217;t set a default charset, so the usual caveats apply. Looking through the mongrel docs, you can do something with the -m option, &#8230; <a href="http://happygiraffe.net/blog/2006/11/18/mongrels-default-charset/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I suddenly noticed that my <a href="http://happygiraffe.net/blog/archives/2006/11/14/java-is-free">last entry</a> had Unicode problems.  How <a href="http://happygiraffe.net/blog/archives/2006/09/16/unicode-for-rails">embarrassing</a>.  It turns out that <a href="http://mongrel.rubyforge.org/">mongrel</a> doesn&#8217;t set a default charset, so the usual <a href="http://tools.ietf.org/html/rfc2616#section-3.7.1" title="default to ISO-8859-1 [or more likely cp1252]">caveats</a> apply.  Looking through the mongrel docs, you can do something with the <code>-m</code> option, but it still seems difficult to apply a default universally.</p>
<p>Thankfully, I&#8217;m proxying to mongrel via Apache.  So correcting the situation turned out to be as simple as adding this to my VirtualHost config.</p>
<pre>
  AddDefaultCharset UTF-8
</pre>
<p>I was actually not sure that this would work, because Apache is proxying rather than serving files directly.  But it does work.  I suspect that it may not work un der Apache 1.3, but that would need to be confirmed.</p>
<p>But now the error is corrected and I&#8217;m Unicode happy once more.  Hurrah!</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/11/18/mongrels-default-charset/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unicode in Rails</title>
		<link>http://happygiraffe.net/blog/2006/10/05/unicode-in-rails/</link>
		<comments>http://happygiraffe.net/blog/2006/10/05/unicode-in-rails/#comments</comments>
		<pubDate>Thu, 05 Oct 2006 09:33:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2006/10/05/unicode-in-rails/</guid>
		<description><![CDATA[Unicode in Rails takes a step further today, as ActiveSupport::MultiByte is committed to the edge (r5223). More information is available over at fingertips, including a neat demo video. This should really help people who need proper Unicode support. There&#8217;s no &#8230; <a href="http://happygiraffe.net/blog/2006/10/05/unicode-in-rails/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Unicode in Rails takes a step further today, as ActiveSupport::MultiByte is committed to the edge (<a href="http://dev.rubyonrails.org/changeset/5223">r5223</a>).  More information is available over at <a href="http://www.fngtps.com/2006/10/activesupport-multibyte">fingertips</a>, including a neat demo video.  This should really help people who need proper Unicode support.  There&#8217;s no excuse to not use <span class="caps">UTF</span>-8 now!</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/10/05/unicode-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Controller Plugins in Rails</title>
		<link>http://happygiraffe.net/blog/2006/10/01/controller-plugins-in-rails/</link>
		<comments>http://happygiraffe.net/blog/2006/10/01/controller-plugins-in-rails/#comments</comments>
		<pubDate>Sun, 01 Oct 2006 22:18:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2006/10/01/controller-plugins-in-rails/</guid>
		<description><![CDATA[I want to write a Rails plugin, which adds a controller to a rails app. It seems like it should be easy, plugins are fairly flexible after all. After a couple of experiments, I concluded that you need at least &#8230; <a href="http://happygiraffe.net/blog/2006/10/01/controller-plugins-in-rails/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I want to write a Rails plugin, which adds a controller to a rails app.  It seems like it should be easy, plugins are fairly flexible after all.  After a couple of experiments, I concluded that you need at least the following defined in your plugin:</p>
<div class="typocode">
<div class="codetitle">lib/foo_controller.rb</div>
<table class="typocode_linenumber">
<tr>
<td class="lineno">
<pre>
1
2
3
4
5
</pre>
</td>
<td width="100%">
<pre><code class="typocode_ruby ">  <span class="keyword">class </span><span class="class">FooController</span> <span class="punct">&lt;</span> <span class="constant">ActionController</span><span class="punct">::</span><span class="constant">Base</span>
    <span class="keyword">def </span><span class="method">hello</span>
      <span class="ident">render</span> <span class="symbol">:text</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">hello world</span><span class="punct">'</span>
    <span class="keyword">end</span>
  <span class="keyword">end</span></code></pre>
</td>
</tr>
</table>
</div>
<div class="typocode">
<div class="codetitle">lib/foo_helper.rb</div>
<table class="typocode_linenumber">
<tr>
<td class="lineno">
<pre>
1
2
</pre>
</td>
<td width="100%">
<pre><code class="typocode_ruby ">  <span class="keyword">module </span><span class="module">FooHelper</span>
  <span class="keyword">end</span></code></pre>
</td>
</tr>
</table>
</div>
<p>But there&#8217;s still a serious problem.  It only works on the first request.  After much mucking around in <a href="http://dev.rubyonrails.org/browser/tags/rel_1-1-6/actionpack/lib/action_controller/routing.rb#L511">routing.rb</a>, I&#8217;ve found out why.  It turns out that when a request is finished, <a href="http://dev.rubyonrails.org/browser/tags/rel_1-1-6/railties/lib/dispatcher.rb#L49">dispatcher.rb</a> clears out all the controllers, so that routing.rb will reload them on the next request (only in development mode).  The problem is, that the controller in the plugin doesn&#8217;t live in one of the &#8220;trusted&#8221; paths<sup><a href="#fn1">1</a></sup>, so can&#8217;t be reloaded.  So, on the second and subsequent requests, you get a routing failure.</p>
<p>There&#8217;s a quick and easy way around this.</p>
<div class="typocode">
<div class="codetitle">lib/foo_controller.rb</div>
<table class="typocode_linenumber">
<tr>
<td class="lineno">
<pre>
1
2
3
4
5
6
7
</pre>
</td>
<td width="100%">
<pre><code class="typocode_ruby ">  <span class="keyword">class </span><span class="class">FooController</span> <span class="punct">&lt;</span> <span class="constant">ActionController</span><span class="punct">::</span><span class="constant">Base</span>
    <span class="keyword">class </span><span class="punct">&lt;&lt;</span> <span class="constant">self</span>
      <span class="keyword">def </span><span class="method">reloadable?</span>
        <span class="constant">false</span>
      <span class="keyword">end</span>
    <span class="keyword">end</span>
  <span class="keyword">end</span></code></pre>
</td>
</tr>
</table>
</div>
<p>But that means that you have to restart the web server each time that you change your plugin, which certainly isn&#8217;t ideal.  At this point, I started thinking about monkey-patching how the reloading works, but a gag reflex caused me to take a step back and think differently.</p>
<p>One minor tip: running <code>rake rails:freeze:gems</code> makes it <em>much</em> easier to dig into the rails source code.  Mostly because it all becomes immediately accessible from within textmate&#8217;s &#8220;Go To File&#8221; command.</p>
<p>Looking around the web, I can&#8217;t find much information about controllers in plugins.  One answer appears to be the <a href="http://rails-engines.org/">rails engines</a> plugins.  But it appears to be more heavyweight than I&#8217;d like.</p>
<p>However, <a href="http://nubyonrails.com/articles/2006/05/04/the-complete-guide-to-rails-plugins-part-i">nuby on rails</a> mentions an interesting alternative.</p>
<blockquote>
<p>You can’t directly write a controller plugin, but you can write a generator that copies a controller to your app/controllers directory.</p>
</blockquote>
<p>The more that I think about this, the more it makes sense to me.  It ensures that magic <span class="caps">URL</span> namespaces don&#8217;t just &#8220;appear&#8221; in your application.  It also provides a point for overriding aspects of the actions I wish to provide.  In addition to all that, it&#8217;s just plain better separated so easier to test.</p>
<p>And I haven&#8217;t even begin to think about how the views are going to work&#8230;</p>
<p id="fn1"><sup>1</sup> <code>app/</code>, <code>lib/</code> and <code>components/</code> according to <a href="http://dev.rubyonrails.org/browser/tags/rel_1-1-6/actionpack/lib/action_controller/routing.rb#L266">safe_load_paths</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/10/01/controller-plugins-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unicode in Rails</title>
		<link>http://happygiraffe.net/blog/2006/09/18/unicode-in-rails-2/</link>
		<comments>http://happygiraffe.net/blog/2006/09/18/unicode-in-rails-2/#comments</comments>
		<pubDate>Mon, 18 Sep 2006 22:51:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2006/09/18/unicode-in-rails-2/</guid>
		<description><![CDATA[I&#8217;m really happy to see that Thijs has just pointed out that the unicode_hacks plugin is undergoing further development: We’re almost ready with a new version of Julik’s ‘Unicode Hacks’ that’s now called ‘ActiveSupport::Multibyte’. You can find more information and &#8230; <a href="http://happygiraffe.net/blog/2006/09/18/unicode-in-rails-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m really happy to see that <a href="http://www.fngtps.com/">Thijs</a> has just <a href="http://happygiraffe.net/blog/archives/2006/09/16/unicode-for-rails#comment-1071">pointed out</a> that the unicode_hacks plugin is undergoing further development:</p>
<blockquote>
<p> We’re almost ready with a new version of Julik’s ‘Unicode Hacks’ that’s now called ‘ActiveSupport::Multibyte’. You can find more information and code <a href="https://fngtps.com/projects/multibyte_for_rails/wiki">on the ‘Multibyte for Rails’ project site</a>.</p>
</blockquote>
<p>I&#8217;m particularly pleased to see that: &#8220;We hope to get ActiveSupport::Multibyte accepted as a new core extension in the 1.2 release of Ruby on Rails&#8221;.  That would be a real boon.  Check out the <a href="https://fngtps.com/projects/multibyte_for_rails/wiki/FAQ"><span class="caps">FAQ</span></a> too.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/09/18/unicode-in-rails-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rails Security Hole</title>
		<link>http://happygiraffe.net/blog/2006/08/10/rails-security-hole/</link>
		<comments>http://happygiraffe.net/blog/2006/08/10/rails-security-hole/#comments</comments>
		<pubDate>Thu, 10 Aug 2006 19:29:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[svk]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2006/08/10/rails-security-hole/</guid>
		<description><![CDATA[Working round the Rails showstopper. (pdcawley)++ (svk)++ I now have the fixed version of typo (soon to be 4.0.2), around an hour after it was committed. As to the whole &#8220;full disclosure&#8221; thing by the rails team? They handled it &#8230; <a href="http://happygiraffe.net/blog/2006/08/10/rails-security-hole/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.bofh.org.uk/articles/2006/08/10/working-round-the-rails-showstopper">Working round the Rails showstopper</a>.</p>
<ul>
<li>(pdcawley)++</li>
<li>(svk)++</li>
</ul>
<p>I now have the fixed version of typo (soon to be 4.0.2), around an hour after it was committed.</p>
<p>As to the whole &#8220;full disclosure&#8221; thing by the rails team?  They handled it pretty badly.  As somebody else <a href="http://blog.evanweaver.com/articles/2006/08/10/explanation-of-the-rails-security-vulnerability-in-1-1-4-others">commented</a>, it <a href="http://www.openssh.com/txt/preauth.adv">didn&#8217;t work</a> for OpenBSD a while back and if anybody could do that, OpenBSD could.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/08/10/rails-security-hole/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unicode for Rails &#8212; accepted</title>
		<link>http://happygiraffe.net/blog/2006/07/30/unicode-for-rails-accepted/</link>
		<comments>http://happygiraffe.net/blog/2006/07/30/unicode-for-rails-accepted/#comments</comments>
		<pubDate>Sun, 30 Jul 2006 20:07:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2006/07/30/unicode-for-rails-accepted/</guid>
		<description><![CDATA[I had a little note today to say that my talk on &#8220;Unicode for Rails&#8221; has been accepted for RailsConf Europe 2006. Yay! Now I have to write the thing. This is going to be interesting. I have only a &#8230; <a href="http://happygiraffe.net/blog/2006/07/30/unicode-for-rails-accepted/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I had a little note today to say that my talk on &#8220;Unicode for Rails&#8221; has been accepted for <a href="http://europe.railsconf.org/">RailsConf Europe 2006</a>.  Yay!</p>
<p>Now I have to write the thing.  This is going to be interesting.  I have only a few weeks to go, and most of those weekends are already taken&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/07/30/unicode-for-rails-accepted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TimedFileStore Plugin 0.1</title>
		<link>http://happygiraffe.net/blog/2006/05/08/timedfilestore-plugin-0-1/</link>
		<comments>http://happygiraffe.net/blog/2006/05/08/timedfilestore-plugin-0-1/#comments</comments>
		<pubDate>Mon, 08 May 2006 21:56:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2006/05/08/timedfilestore-plugin-0-1/</guid>
		<description><![CDATA[My first rails plugin: timed_file_store is now available. It lets you expire fragments based upon the time of the cached file. It&#8217;s fairly easy to use; just bung this into config/environments.rb: ActionController::Base.fragment_cache_store = TimedFileStore.new("#{RAILS_ROOT}/tmp/cache", :atime =&#62; 15.minutes) And now any &#8230; <a href="http://happygiraffe.net/blog/2006/05/08/timedfilestore-plugin-0-1/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My first rails plugin: <a href="http://happygiraffe.net/svn/public/timed_file_store/tags/rel_0-1/">timed_file_store</a> is now available.  It lets you expire fragments based upon the time of the cached file.  It&#8217;s fairly easy to use; just bung this into <code>config/environments.rb</code>:</p>
<pre>
  ActionController::Base.fragment_cache_store =
    TimedFileStore.new("#{RAILS_ROOT}/tmp/cache", :atime =&gt; 15.minutes)
</pre>
<p>And now any fragments which haven&#8217;t been accessed in the last 15 minutes will be removed the next time that they&#8217;re accessed.</p>
<p>This is rather coarse&#8212;it applies to all fragments.  But it&#8217;s also pretty simple and does what I need for now.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/05/08/timedfilestore-plugin-0-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Fragment Cache Expiry</title>
		<link>http://happygiraffe.net/blog/2006/05/07/rails-fragment-cache-expiry/</link>
		<comments>http://happygiraffe.net/blog/2006/05/07/rails-fragment-cache-expiry/#comments</comments>
		<pubDate>Sun, 07 May 2006 22:20:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2006/05/07/rails-fragment-cache-expiry/</guid>
		<description><![CDATA[I&#8217;ve been looking at Rails&#8217; fragment caching recently. I want to cache some stuff in my view that&#8217;s more or less independent of my model (eg: output from some slow command like top). That&#8217;s fine, and easily done. &#60;% cache &#8230; <a href="http://happygiraffe.net/blog/2006/05/07/rails-fragment-cache-expiry/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been looking at Rails&#8217; <a href="http://api.rubyonrails.org/classes/ActionController/Caching/Fragments.html">fragment caching</a> recently.  I want to cache some stuff in my view that&#8217;s more or less independent of my model (eg: output from some slow command like top).  That&#8217;s fine, and easily done.</p>
<pre>
  &lt;% cache do %&gt;
    &lt;%=h `top` %&gt;
  &lt;% end %&gt;
</pre>
<p>The trouble is expiry (as it always is with caching).  By default, Rails offers you things like <code>expire_fragment</code> and <a href="http://api.rubyonrails.org/classes/ActionController/Caching/Sweeping.html">Sweeping</a>, but these are very much tied in to the Model classes.</p>
<p>What I really need is to know the timestamp of each entry in the cache, so I can make judgements based on that.  Unfortunately, at present, ActionController seems to treat each cache entry as little more than a blob of data.  I need to store metadata with it, like when it was last accessed and when it was put in the cache.  I&#8217;m not sure that I can do that in the current framework.</p>
<p>It looks like I&#8217;m not the only one who wants this: see also <a href="http://blog.tourb.us/archives/time-based-cache/">Time-based fragment caching in Rails</a>.  I&#8217;m not 100% sure I like that solution, but it does look like it would work.  Perhaps I&#8217;m too institutionalized towards cron?  I&#8217;d definitely rather avoid using cron if I can possibly help it (lesson from work: system dependencies are <strong>bad</strong>).</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/05/07/rails-fragment-cache-expiry/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Typo Upgrade</title>
		<link>http://happygiraffe.net/blog/2006/04/17/typo-upgrade/</link>
		<comments>http://happygiraffe.net/blog/2006/04/17/typo-upgrade/#comments</comments>
		<pubDate>Mon, 17 Apr 2006 14:35:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[blogs]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[sitemaps]]></category>
		<category><![CDATA[svk]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[typo]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2006/04/17/typo-upgrade/</guid>
		<description><![CDATA[I&#8217;ve finally bit the bullet and upgraded Typo to the trunk, so I can get everything up to Rails 1.1. Unfortunately, this was quite a painful process&#8230; Normally, I track bits of software I might want to hack on in &#8230; <a href="http://happygiraffe.net/blog/2006/04/17/typo-upgrade/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve finally bit the bullet and upgraded Typo to the trunk, so I can get everything up to Rails 1.1.  Unfortunately, this was quite a painful process&#8230;</p>
<p>Normally, I track bits of software I might want to hack on in a <a href="http://svnbook.red-bean.com/en/1.0/ch07s04.html">vendor branch</a> in subversion, and use svn_load_dirs.pl to update to new releases.  This works extremely well with wordpress at work, for instance.</p>
<p>Sadly, svn_load_dirs.pl couldn&#8217;t cope with the typo trunk, as a directory got replaced by a symlink.  Ooops.  I tried working around it, but eventually, it was easier to give up and start afresh, redoing the changes I&#8217;d already made in subversion.  I suppose it would have been a lot easier with <a href="http://svk.elixus.org/"><span class="caps">SVK</span></a>.</p>
<p>Unfortunately, a number of things haven&#8217;t caught up with the latest typo changes.  In particular, the origami theme that I was using needs some loving attention.  So it&#8217;s back to the default theme, &#8220;azure&#8221; for the moment, until I can spend some time on it.</p>
<p>Also, I couldn&#8217;t figure out how to make the google sitemaps patch work, so that&#8217;s another &#8220;gone for now&#8221; feature.</p>
<p>Please let me know if you spot anything else&#8230;</p>
<p><strong>Update</strong>: Comments now enabled.  Sorry about that.</p>
<p><strong>Update#2</strong>: I&#8217;ve now fixed the comments feed a bit.  It turns out that one of the migrations missed out on creating guids for all the comments&#8230;</p>
<pre>
  % ruby script/console production
  &gt;&gt; comments = Comment.find_all
  &gt;&gt; comments.reject { |c| c.guid }.each { |c| c.create_guid; c.save }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/04/17/typo-upgrade/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

