<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>jvoorhis comments on Quick add slashes filter for Rails</title>
    <link>http://www.jvoorhis.com/</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>jvoorhis comments</description>
    <item>
      <title>"Quick add slashes filter for Rails" by jvoorhis</title>
      <description>&lt;pre&gt;&lt;code&gt;
def add_slash
  unless %r{/$}.match(@request.path)
    redirect_to @request.path &amp;lt;&amp;lt; '/'
  end
end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;This ensures you always have the trailing slash at the end of your URLs. Maybe it could be done better, but for now it works. &lt;a href="http://djangoproject.com/"&gt;Django&lt;/a&gt; has some stock middleware that does just this, as well as ensuring the first part of the hostname is &amp;#8216;www&amp;#8217;. The point is that your resource can be accessed with one and only one &lt;span class="caps"&gt;URL&lt;/span&gt;, rather than with potentially 4 combinations of / and www. I have no hard evidence, but this is supposedly good for teh Google, and some people find it elegant.&lt;/p&gt;


	&lt;p&gt;I am thinking about maybe whipping up a module of such utilities that you could include in your &lt;code&gt;ApplicationController&lt;/code&gt; and never think about again.&lt;/p&gt;

</description>
      <pubDate>Mon, 10 Oct 2005 07:25:03 NZDT</pubDate>
      <guid>&lt;a href="/articles/2005/10/10/quick-add-slashes-filter-for-rails"&gt;Quick add slashes filter for Rails&lt;/a&gt;</guid>
      <link>&lt;a href="/articles/2005/10/10/quick-add-slashes-filter-for-rails"&gt;Quick add slashes filter for Rails&lt;/a&gt;</link>
    </item>
  </channel>
</rss>
