<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Eschew Obfuscation: Category Ruby on Rails</title>
    <link>http://blog.maxdunn.com/articles/category/ruby-on-rails</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Max Dunn's Personal Blog</description>
    <item>
      <title>Migrations With Referential Integrity</title>
      <description>&lt;p&gt;Migrations don’t come with referential integrity directives, best as I can tell. There are some plugins but it appeared to me (ok, after only a brief review) that they were more focused on adding referential integrity for rails object hierarchies (:belongs_to etc.), so that seemed both overkill and insufficient for what I needed to do.&lt;/p&gt;


	&lt;p&gt;But it turns out that an “execute” statement in the migration lets you issue sql directives directly.&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;create_table "dvectors", :id =&amp;gt; false, :force =&amp;gt; true do |t|
  t.column "length",      :integer, :default =&amp;gt; -1
  t.column "fvector",     :binary
  t.column "document_id", :integer, :default =&amp;gt; -1
  t.column "total_size",  :integer, :default =&amp;gt; 0
end
add_index "dvectors", ["document_id"], :name =&amp;gt; "document_id" 
execute "alter table dvectors add constraint `dvectors_fk` " +
        "foreign key (`document_id`) references `documents` (`id`) on delete cascade"&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;(Submitted by Wido Menhardt)&lt;/p&gt;</description>
      <pubDate>Tue, 15 May 2007 11:11:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:77732030-df55-4b1c-9fa0-12cc38849a21</guid>
      <author>Max Dunn</author>
      <link>http://blog.maxdunn.com/articles/2007/05/15/migrations-with-referential-integrity</link>
      <category>Ruby on Rails</category>
    </item>
    <item>
      <title>Typo Google Sitemap fix</title>
      <description>&lt;p&gt;I guess Google used to be more lenient in the format of their &lt;a href="http://www.google.com/webmasters/sitemaps"&gt;Sitemaps&lt;/a&gt;. However, when I installed Typo 4.0.3 and submitted a sitemap, Google didn&amp;#8217;t like the format.&lt;/p&gt;


	&lt;p&gt;The format of the &lt;a href="https://www.google.com/webmasters/tools/docs/en/protocol.html#sitemapXMLFormat"&gt;Google Sitemap&lt;/a&gt; is straightforward:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt; &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;
  &amp;lt;urlset xmlns=&amp;quot;http://www.google.com/schemas/sitemap/0.84&amp;quot;&amp;gt;
   &amp;lt;url&amp;gt;
    &amp;lt;loc&amp;gt;http://www.example.com/&amp;lt;/loc&amp;gt;
    &amp;lt;lastmod&amp;gt;2005-01-01&amp;lt;/lastmod&amp;gt;
    &amp;lt;changefreq&amp;gt;monthly&amp;lt;/changefreq&amp;gt;
    &amp;lt;priority&amp;gt;0.8&amp;lt;/priority&amp;gt;
   &amp;lt;/url&amp;gt;  
  &amp;lt;/urlset&amp;gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;However, Typo 4.0.3 and Typo edge (as of 15-Jan-2007) both used &amp;#8220;item&amp;#8221; instead of &amp;#8220;url&amp;#8221; and &amp;#8220;link&amp;#8221; instead of &amp;#8220;loc&amp;#8221;.&lt;/p&gt;


	&lt;p&gt;Luckily the fix is easy. Edit all 4 &lt;code&gt;_googlesitemap_item_*.rxml&lt;/code&gt; files in /app/views/xml and change &amp;#8220;xm.item&amp;#8221; to &amp;#8220;xm.url&amp;#8221; and &amp;#8220;xm.link&amp;#8221; to &amp;#8220;xm.loc&amp;#8221;.  For instance, &lt;code&gt;_googlesitemap_item_article.rxml&lt;/code&gt; will look like:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;xm&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;url&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
  &lt;span class="ident"&gt;xm&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;loc&lt;/span&gt; &lt;span class="ident"&gt;post_link&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;item&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
  &lt;span class="ident"&gt;xm&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;lastmod&lt;/span&gt; &lt;span class="ident"&gt;item&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;updated_at&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;xmlschema&lt;/span&gt;
  &lt;span class="ident"&gt;xm&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;priority&lt;/span&gt; &lt;span class="number"&gt;0.8&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Now make similar changes to the other 3 files. When done, go into Typo Admin, Settings, Cache and select &amp;#8220;Rebuild cached &lt;span class="caps"&gt;HTML&lt;/span&gt;&amp;#8221;. Now you can submit a sitemap like http://blog.maxdunn.com/sitemap.xml to Google Sitemaps and it will work!&lt;/p&gt;</description>
      <pubDate>Tue, 16 Jan 2007 08:59:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:dbdcd905-8c89-4dce-b7ef-c10c0f9c9f96</guid>
      <author>Max Dunn</author>
      <link>http://blog.maxdunn.com/articles/2007/01/16/typo-google-sitemap-fix</link>
      <category>Ruby on Rails</category>
    </item>
    <item>
      <title>Differences between RewriteRule in .htaccess and httpd.conf</title>
      <description>&lt;p&gt;This is probably obvious to people who know Apache well, but I just spent a half day struggling with the differences between RewriteRule in .htaccess and httpd.conf. I was assuming they would behave the same way, but there are slight differences:&lt;/p&gt;


	&lt;h2&gt;Differences&lt;/h2&gt;


	&lt;h4&gt;httpd.conf&lt;/h4&gt;


	&lt;ul&gt;
	&lt;li&gt;The request &lt;span class="caps"&gt;URI&lt;/span&gt; will have a leading slash&lt;/li&gt;
		&lt;li&gt;The leading slash needs to remain to find cached files&lt;/li&gt;
		&lt;li&gt;When using -f or !-f, it needs to have the document root on front&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h4&gt;.htaccess&lt;/h4&gt;


	&lt;ul&gt;
	&lt;li&gt;The request &lt;span class="caps"&gt;URI&lt;/span&gt; won&amp;#8217;t have a leading slash&lt;/li&gt;
		&lt;li&gt;Can&amp;#8217;t have a leading slash to find cached files&lt;/li&gt;
		&lt;li&gt;When using -f or !-f, don&amp;#8217;t use the document root&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h2&gt;Examples&lt;/h2&gt;


	&lt;p&gt;Here is an example that looks in the public/cache directory for cached files:&lt;/p&gt;


	&lt;h4&gt;httpd.conf&lt;/h4&gt;


&lt;code&gt;
&lt;pre&gt;
RewriteRule ^/$ /cache/index.html [QSA]
RewriteRule ^/([^.]+)$ /cache/$1.html [QSA]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
&lt;/pre&gt;
&lt;/code&gt;

	&lt;h4&gt;.htaccess&lt;/h4&gt;


&lt;code&gt;
&lt;pre&gt;
RewriteRule ^$ cache/index.html [QSA]
RewriteRule ^([^.]+)$ cache/$1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
&lt;/pre&gt;
&lt;/code&gt;

	&lt;h4&gt;Rails&lt;/h4&gt;


	&lt;p&gt;Just to complete this example, add this line to a before_filter method in application.rb to have Rails cache files to this directory:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;ApplicationController::page_cache_directory = "#{RAILS_ROOT}/public/cache"&lt;/code&gt;&lt;/pre&gt;</description>
      <pubDate>Fri, 12 Jan 2007 15:08:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:eef91d5b-d7e3-461f-86eb-6d243910764a</guid>
      <author>Max Dunn</author>
      <link>http://blog.maxdunn.com/articles/2007/01/12/differences-between-rewriterule-in-htaccess-and-httpd-conf</link>
      <category>Ruby on Rails</category>
      <category>Tech Tips</category>
    </item>
    <item>
      <title>Installing MySQL Ruby Gem on Mac OS X 10.4</title>
      <description>&lt;p&gt;There are some problems installing the Ruby Gem MySQL on the Mac 10.4. When you do a:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;sudo gem install mysql&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;you will likely get an error like:&lt;/p&gt;


&lt;code&gt;
&lt;pre&gt;
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.
&lt;/pre&gt;
&lt;/code&gt;

	&lt;p&gt;To fix this problem, run this:&lt;/p&gt;


&lt;code&gt;
&lt;pre&gt;
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
&lt;/pre&gt;
&lt;/code&gt;

	&lt;p&gt;(Solution From &lt;a href="http://wiki.rubyonrails.com/rails/pages/HowtoInstallOnOSXTiger#7"&gt;How to Install on &lt;span class="caps"&gt;OSX&lt;/span&gt;&lt;/a&gt;)&lt;/p&gt;


	&lt;p&gt;Next, you will probably see this error:&lt;/p&gt;


&lt;code&gt;
&lt;pre&gt;
mysql.c: In function 'Init_mysql':
mysql.c:2015: error: 'ulong' undeclared (first use in this function)
...
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;To fix this, change to /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7 and  edit &amp;#8220;mysql.c&amp;#8221; to add this to the top:&lt;/p&gt;


&lt;code&gt;
&lt;pre&gt;
#define ulong unsigned long
&lt;/pre&gt;
&lt;/code&gt;

	&lt;p&gt;(Solution from: &lt;a href="http://www.railtie.net/articles/2006/09/12/running-rails-on-os-x-with-mysql-5-0-24"&gt;I.NFECTIO.US&lt;/a&gt;)&lt;/p&gt;


	&lt;p&gt;Now recompile with:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;sudo make
sudo make install
sudo make clean&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;That should do it!&lt;/p&gt;</description>
      <pubDate>Tue, 12 Dec 2006 23:14:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:39ce37c7-30bf-445e-baf4-433574dc28f8</guid>
      <author>Max Dunn</author>
      <link>http://blog.maxdunn.com/articles/2006/12/12/installing-mysql-gem-on-mac-os-x-10-4</link>
      <category>Ruby on Rails</category>
      <category>Tech Tips</category>
    </item>
    <item>
      <title>&amp;quot;svn: Malformed network data&amp;quot; error in Eclipse</title>
      <description>&lt;p&gt;Several weeks ago, I changed from a Windows laptop to a MacBook. After I got Eclipse setup and went to check-in some code to RubyForge, I received an error:&lt;/p&gt;
	&lt;pre&gt;&lt;code&gt;svn: Commit failed (details follow):
svn: Malformed network data&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;At first I figured that this was just a problem with the RadRails Subclipse module on my Mac, but then I tried it on my old Windows computer that used to work fine, and got the same error!&lt;/p&gt;


	&lt;p&gt;After googling around, it seems that this is a known issue when &lt;span class="caps"&gt;SVN&lt;/span&gt; server is updated to version 1.4, but older clients are used. The clients were fixed in October, but there hasn&amp;#8217;t been a new official Subclipse build so the automatic Eclipse update doesn&amp;#8217;t help. I spent a day trying to figure out how to compile a new Eclipse version, but no luck.&lt;/p&gt;


	&lt;p&gt;However, there are two workarounds. First, the svn command line works fine.&lt;/p&gt;


	&lt;p&gt;The second workaround relies on the fact that the changed files are actually committed, but that the error just prevents the local svn repository from recognizing that. So after the error, doing an &amp;#8220;update&amp;#8221; will merge the changes and everything will be good.&lt;/p&gt;


	&lt;p&gt;If you have added or deleted files, however, the update trick won&amp;#8217;t work. In this case, it is necessary to delete the entire directory that contains the added or deleted files. &lt;strong&gt;Be sure to do this outside of Eclipse with Explorer or Finder!&lt;/strong&gt; Then update the files and it will bring everything down fine.&lt;/p&gt;


	&lt;h4&gt;Versions&lt;/h4&gt;


	&lt;table&gt;
		&lt;tr&gt;
			&lt;th&gt;Program&lt;/th&gt;
			&lt;th&gt;Version&lt;/th&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;RadRails&lt;/td&gt;
			&lt;td&gt;v.0.7.1&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;Subclipse&lt;/td&gt;
			&lt;td&gt;1.0.3&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;svn command line&lt;/td&gt;
			&lt;td&gt;1.3.1&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/table&gt;




	&lt;h2&gt;Fix&lt;/h2&gt;


	&lt;p&gt;Mark Phippard added a comment explaining the problem. Here is a summary:&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;The issue is JavaSVN. It had a problem talking to Subversion 1.4.x server. RadRails can be used with Eclipse 3.2 and then you can install Subclipse 1.1.9 which includes &lt;span class="caps"&gt;SVN 1&lt;/span&gt;.4 clients.&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;So I installed Eclipse 3.2 and RadRails on top. However, when I installed Subclipse according to the instructions:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;Eclipse: Help =&amp;gt; Software Updates =&amp;gt; Find and Install&lt;/li&gt;
		&lt;li&gt;Search for new features to install&lt;/li&gt;
		&lt;li&gt;New Remote Site&lt;/li&gt;
		&lt;li&gt;&lt;span class="caps"&gt;URL&lt;/span&gt; =&amp;gt; http://subclipse.tigris.org/update_1.0.x&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;it gave me version Subclipse 1.0.3. The trick to get Subclipse 1.1.9 was to use the update site:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;span class="caps"&gt;URL&lt;/span&gt; =&amp;gt; http://subclipse.tigris.org/update_1.2.x&lt;/li&gt;
	&lt;/ul&gt;</description>
      <pubDate>Thu, 07 Dec 2006 10:37:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:d330791c-c5b0-407a-a7e8-25bee9319447</guid>
      <author>Max Dunn</author>
      <link>http://blog.maxdunn.com/articles/2006/12/07/svn-malformed-network-data-error-in-eclipse</link>
      <category>Ruby on Rails</category>
      <category>Tech Tips</category>
    </item>
    <item>
      <title>Ruby on Rails Camp Was A Success</title>
      <description>&lt;p&gt;Wow, the &lt;a href="http://www.rubyonrailscamp.com"&gt;Ruby on Rails Camp&lt;/a&gt; really went well!&lt;/p&gt;


	&lt;p&gt;Beforehand, our biggest fear with this &lt;a href="http://www.rubyonrailscamp.com/Unconference+Info"&gt;unconference&lt;/a&gt; format was that only a few people would want to lead a session. So our hearts stopped momentarily when when we called for sessions and only 6 people initially came down. But after a few minutes, a bunch of other people started coming down and we quickly filled up the schedule with 28 &lt;a href="http://www.rubyonrailscamp.com/Schedules"&gt;sessions.&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Besides the great sessions, the &lt;a href="http://www.rubyonrailscamp.com/Speed+Geeking"&gt;speed demo&lt;/a&gt; was very popular.&lt;/p&gt;


	&lt;p&gt;People were also very impressed with the beautiful &lt;span class="caps"&gt;IBM&lt;/span&gt; facility and terrific food and drinks they provided, as well as the free coffee barista and sushi dinner made possible by our other sponsors. Thanks again to &lt;span class="caps"&gt;IBM&lt;/span&gt; for hosting the event and providing all the food and refreshments, and our other &lt;a href="http://www.rubyonrailscamp.com/Sponsors"&gt;sponsors&lt;/a&gt; for making this possible!&lt;/p&gt;


	&lt;p&gt;We had a lot of great &lt;a href="http://www.rubyonrailscamp.com/Feedback"&gt;feedback&lt;/a&gt; about the camp. &lt;a href="http://www.rubyonrailscamp.com/Greg+Tomei"&gt;Greg Tomei&lt;/a&gt; said &lt;em&gt;&amp;#8220;Wow &amp;#8211; my expectations were exceeded by a huge measure!&amp;#8221;&lt;/em&gt; and &lt;a href="http://www.rubyonrailscamp.com/Dav+Yaginuma"&gt;Dav Yaginuma&lt;/a&gt; said &lt;em&gt;&amp;#8220;The very first session on memcached was perhaps the most perfect conference session I&amp;#8217;d ever attended.&amp;#8221;&lt;/em&gt;&lt;/p&gt;


	&lt;p&gt;But the real thanks should go to all you attendees &amp;#8211; it was your efforts that really made this unconference a success!&lt;/p&gt;</description>
      <pubDate>Mon, 20 Nov 2006 12:15:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:4a5ef7b9-6819-40a6-b8fc-aac7f74703e1</guid>
      <author>Max Dunn</author>
      <link>http://blog.maxdunn.com/articles/2006/11/20/ruby-on-rails-camp-was-a-success</link>
      <category>Ruby on Rails</category>
    </item>
    <item>
      <title>Ruby on Rails Camp</title>
      <description>&lt;p&gt;It&amp;#8217;s here! Ever since &lt;a href="http://www.rubyonrailscamp.com/Wido+Menhardt"&gt;Wido&lt;/a&gt; and I went to the &lt;a href="http://www.mashupcamp.com/"&gt;MashupCamp&lt;/a&gt; in July, we wanted to do a similar unconference for &lt;a href="http://www.rubyonrails.org/"&gt;Ruby on Rails&lt;/a&gt; (RoR). So we have been looking around for locations and figuring out dates, and now have everything finalized.  The &lt;a href="http://www.rubyonrailscamp.com/"&gt;Ruby on Rails Camp&lt;/a&gt; is going to be November 9th at &lt;span class="caps"&gt;IBM&lt;/span&gt; Almaden in San Jose, California.&lt;/p&gt;


	&lt;h3&gt;Is Ruby on Rails Ready for Business?&lt;/h3&gt;


	&lt;p&gt;The focus will be on whether RoR is ready for real-world, real-business applications. Will it scale? Will I be able to hire developers? Will it persist? Will there be support? Will it be compatible with my other applications? Will there be enough third-party components? Will I be able to get funding? These are all &lt;a href="http://www.rubyonrailscamp.com/Session+Ideas"&gt;issues&lt;/a&gt; we hope to talk about, as well as other general Ruby and Rails topics.&lt;/p&gt;


	&lt;h3&gt;Unconference&lt;/h3&gt;


	&lt;p&gt;We are calling it a &amp;#8220;camp&amp;#8221; rather than a &amp;#8220;conference&amp;#8221; because it will be held in the &lt;a href="http://en.wikipedia.org/wiki/Unconference"&gt;Unconference&lt;/a&gt; style. So instead of having preset speakers and sessions, the first thing that will happen is that we will ask the participants to decide what &lt;a href="http://www.rubyonrailscamp.com/session+ideas"&gt;sessions&lt;/a&gt; they would like to give themselves.&lt;/p&gt;


	&lt;p&gt;There will also be a SpeedDemo sessions so that participants can show off their own RoR applications &amp;#8211; whether they are commercially polished or just something hacked together for fun. This will be a great way to see what you can do with RoR!&lt;/p&gt;


	&lt;h3&gt;Fee&lt;/h3&gt;


	&lt;p&gt;We debated on whether to charge a fee and decided on a small fee of $25 to reduce the number of no-shows. We also are planning to have &lt;a href="http://www.kaliyasblogs.net"&gt;Kaliya Hamlin&lt;/a&gt; facilitate the camp, and the fee will help make that possible.&lt;/p&gt;


	&lt;h3&gt;Signups&lt;/h3&gt;


	&lt;p&gt;So if you are developing a Ruby on Rails business application &amp;#8211; or would like to &amp;#8211; or are just interested in learning more about Ruby on Rails, you should definitely come to the &lt;a href="http://www.rubyonrailscamp.com"&gt;Ruby on Rails Camp!&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 10 Oct 2006 08:54:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:4f44ac39-c990-4569-abf8-33b8fa7d7910</guid>
      <author>Max Dunn</author>
      <link>http://blog.maxdunn.com/articles/2006/10/10/ruby-on-rails-camp</link>
      <category>Ruby on Rails</category>
    </item>
    <item>
      <title>Apache Redirects to the Rescue</title>
      <description>&lt;p&gt;There are a couple of technical problems with my web site. The first is that to get into this blog, you need to add the trailing slash at the end of &amp;#8220;typo&amp;#8221; like this: &lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;http://www.maxdunn.com/typo/&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;Otherwise, the wiki gives a page not found error for the &amp;#8220;typo&amp;#8221; page. Of course, when most people type in the &lt;span class="caps"&gt;URL&lt;/span&gt; manually, they won&amp;#8217;t add the trailing slash and then get confused when it doesn&amp;#8217;t pull up my blog.&lt;/p&gt;


	&lt;p&gt;I have tried various things in the Rails routing.rb file to correct for this, but none worked. However, a simple change to .htaccess did the trick:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;RedirectMatch permanent ^/typo$ http://www.maxdunn.com/typo/&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;Now another problem I have is that my &lt;span class="caps"&gt;ISP&lt;/span&gt; &lt;a href="http://www.site5.com"&gt;Site5&lt;/a&gt; maps maxdunn.com to www.maxdunn.com and there is no way to turn this off. This causes several problems:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;When logged into &lt;strong&gt;www.maxdunn.com&lt;/strong&gt;, you won&amp;#8217;t be logged in if you access it as &lt;strong&gt;maxdunn.com&lt;/strong&gt;.&lt;/li&gt;
		&lt;li&gt;If someone first accesses the site using &lt;strong&gt;maxdunn.com&lt;/strong&gt;, then the page cache will create all links as &lt;strong&gt;maxdunn.com&lt;/strong&gt; and serve these up, even if the page is later accessed as &lt;strong&gt;www.maxdunn.com&lt;/strong&gt;.&lt;/li&gt;
		&lt;li&gt;If the site is accessed with both &lt;strong&gt;maxdunn.com&lt;/strong&gt; and &lt;strong&gt;www.maxdunn.com&lt;/strong&gt;, then Google and other search engines will think these are two sites and neither will be ranked as highly.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;To fix this problem, there is another simple .htaccess addition that will redirect all &lt;strong&gt;maxdunn.com&lt;/strong&gt; requests to &lt;strong&gt;www.maxdunn.com&lt;/strong&gt;:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;RewriteCond %{HTTP_HOST} ^maxdunn.com$ [NC]
RewriteRule ^(.*)$ http://www.maxdunn.com/$1 [L,R=301]&lt;/code&gt;&lt;/pre&gt;</description>
      <pubDate>Sat, 07 Oct 2006 12:36:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:842caffa-e0d2-44de-beef-56bfb91796db</guid>
      <author>Max Dunn</author>
      <link>http://blog.maxdunn.com/articles/2006/10/07/apache-redirects-to-the-rescue</link>
      <category>Ruby on Rails</category>
      <category>Tech Tips</category>
    </item>
    <item>
      <title>Ruby on Rails Advanced Page Caching</title>
      <description>&lt;p&gt;Ruby on Rails (RoR or Rails) has some cool caching mechanisms already built in. You can cache parts of pages (fragment caching) or whole pages (action caching) while still going into your Rails code to check for permissions or do other things. However, for the highest performance, you can use page caching which serves the web page without even starting Rails, making it incredibly fast. For instance, on my slow computer, doing action caching was 2 times faster than normal, but doing page caching was 30 times faster! (See &lt;a href="http://www.maxdunn.com/typo/articles/2006/09/12/ruby-on-rails-caching-benchmarks"&gt;Ruby on Rails Caching Benchmarks&lt;/a&gt;).&lt;/p&gt;


	&lt;p&gt;However, the problem I ran into was that when you are logged into &lt;a href="http://www.maxdunn.com"&gt;my wiki&lt;/a&gt; as an editor, you see an &amp;#8220;Edit&amp;#8221; link on each section of the page, and if you are logged in as an admin, you see an &amp;#8220;Admin&amp;#8221; choice on the menu. So while the Rails action caching would work fine for this, I couldn&amp;#8217;t use the Rails out-of-the-box page caching since if I was logged in as an Editor and browsed through the pages, the next person that looked at the pages would still see all the &amp;#8220;Edit&amp;#8221; links, even if they were not logged in!&lt;/p&gt;


	&lt;p&gt;After some thought, I came up with two solutions for solving this problem. The first was based on rewriting the &lt;span class="caps"&gt;URL&lt;/span&gt; depending on what role the user is logged in as. I then came up with a better method that relies on setting a cookie with the current role and then using Javascript to modify the page appropriately. Here are the details on both methods.&lt;/p&gt;</description>
      <pubDate>Sat, 16 Sep 2006 13:02:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:6965e239-2b68-4f0a-aa97-427f9eb9575c</guid>
      <author>Max Dunn</author>
      <link>http://blog.maxdunn.com/articles/2006/09/16/ruby-on-rails-advanced-page-caching</link>
      <category>Ruby on Rails</category>
    </item>
    <item>
      <title>Ruby on Rails Better Wiki URLs</title>
      <description>&lt;p&gt;Normally links in a wiki would appear like this:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;nowiki&gt;http://www.maxdunn.com/show/Ruby+on+Rails&lt;/nowiki&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;However, I wanted the URLs in &lt;a href="http://www.maxdunn.com"&gt;my wiki&lt;/a&gt; to look more like web pages:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;nowiki&gt;http://www.maxdunn.com/Ruby+on+Rails&lt;/nowiki&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;It is simple to do this and here are the details:&lt;/p&gt;</description>
      <pubDate>Sat, 16 Sep 2006 11:36:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:48a9a868-9bb2-4608-bdc3-88daf9ed1569</guid>
      <author>Max Dunn</author>
      <link>http://blog.maxdunn.com/articles/2006/09/16/ruby-on-rails-better-wiki-urls</link>
      <category>Ruby on Rails</category>
    </item>
    <item>
      <title>Ruby on Rails Caching Benchmarks</title>
      <description>&lt;p&gt;I have been working on optimizing my &lt;a href="http://www.maxdunn.com"&gt;Ruby on Rails wiki&lt;/a&gt; so that it can stand up under heavy load. The first step I took was to implement caching so that the pages don&amp;#8217;t need to be re-rendered each time. This is especially important in my wiki since each page can have 6 different sections that need to be rendered:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;header&lt;/li&gt;
		&lt;li&gt;menu&lt;/li&gt;
		&lt;li&gt;footer&lt;/li&gt;
		&lt;li&gt;left column&lt;/li&gt;
		&lt;li&gt;middle column&lt;/li&gt;
		&lt;li&gt;right column.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;I did some quick benchmarks that might be useful for others that are optimizing their RoR apps:&lt;/p&gt;


	&lt;table&gt;
		&lt;tr&gt;
			&lt;th&gt;Caching Method &amp;nbsp; &lt;/th&gt;
			&lt;th&gt; Page Load Time &amp;nbsp;&lt;/th&gt;
			&lt;th&gt;Pages per Second &lt;/th&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;None&lt;/td&gt;
			&lt;td&gt;620ms&lt;/td&gt;
			&lt;td&gt;1.6&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;Action&lt;/td&gt;
			&lt;td&gt;270ms&lt;/td&gt;
			&lt;td&gt;3.7&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;Page&lt;/td&gt;
			&lt;td&gt;18ms&lt;/td&gt;
			&lt;td&gt;55&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/table&gt;




	&lt;p&gt;These times were produced with the web load testing program &lt;a href="http://grinder.sourceforge.net/"&gt;The Grinder&lt;/a&gt; on my Averatec &lt;span class="caps"&gt;AMD 2800&lt;/span&gt;+ laptop using WEBrick running Windows XP and Rails in development mode.&lt;/p&gt;


	&lt;p&gt;The main conclusion is that while utilizing Action caching doubled the performance, using Page caching increased the performance over 30 times!&lt;/p&gt;</description>
      <pubDate>Tue, 12 Sep 2006 17:56:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:1dc7614a-b102-403c-87de-35072014427a</guid>
      <author>Max Dunn</author>
      <link>http://blog.maxdunn.com/articles/2006/09/12/ruby-on-rails-caching-benchmarks</link>
      <category>Ruby on Rails</category>
    </item>
    <item>
      <title>Getting Started With Flickr on Rails</title>
      <description>&lt;p&gt;I have been working on a Flickr mashup on my wiki so that I can easily insert links to my Flickr pictures. There are several Flickr libraries for Rails, but the documentation is not very good. So here are some instructions for getting a Flickr library working with Rails.&lt;/p&gt;


	&lt;p&gt;(&lt;strong&gt;Note&lt;/strong&gt;: On August 28, 2006, I expanded and updated these instructions at: &lt;a href="http://www.maxdunn.com/RoR+and+Flickr"&gt;http://www.maxdunn.com/RoR+and+Flickr&lt;/a&gt;)&lt;/p&gt;</description>
      <pubDate>Thu, 06 Jul 2006 10:47:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:4ae1d1cd-481d-4243-a681-3d6becd43759</guid>
      <author>Max Dunn</author>
      <link>http://blog.maxdunn.com/articles/2006/07/06/getting-started-with-flickr-on-rails</link>
      <category>Ruby on Rails</category>
      <category>Tech Tips</category>
    </item>
    <item>
      <title>Google Map Mashup in Rails</title>
      <description>&lt;p&gt;How would you like to put an interactive Google map in your Ruby on Rails page with single or multiple markers? Here is how to do this.&lt;/p&gt;</description>
      <pubDate>Fri, 30 Jun 2006 10:03:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:b7737160-1edc-4bbc-9106-7ffb48a199a1</guid>
      <author>Max Dunn</author>
      <link>http://blog.maxdunn.com/articles/2006/06/30/google-map-mashup-in-rails</link>
      <category>Tech Tips</category>
      <category>Ruby on Rails</category>
    </item>
    <item>
      <title>Ruby on Rails</title>
      <description>&lt;p&gt;I have been working on a web site for my son&amp;#8217;s baseball club, &lt;a href="http://tricitiesbaseball.org"&gt;Tri-Cities Baseball&lt;/a&gt;, with my wife Suzanne and our friend Steve Cousins, and it has been a lot of fun.&lt;/p&gt;


	&lt;p&gt;Suzanne has been doing the graphical design and static pages, and Steve and I have been working on the  &lt;a href="http://tricitiesbaseball.org/store/register"&gt;registration&lt;/a&gt; part using Ruby on Rails (RoR).&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.rubyonrails.com/"&gt;RoR&lt;/a&gt; is a fantastic environment that makes it easy to develop, deploy and maintain web applications, particularly for doing data-base backed web sites.&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.rubycentral.com/"&gt;Ruby&lt;/a&gt; by itself is a great object oriented language, that provides all the benefits of object orientation, without the downfalls of pure(object(languages(like(lisp)))). (That was a Lisp joke. ;-)&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.rubyonrails.com/"&gt;Rails&lt;/a&gt; is a framework that uses a Model-View-Controller (MVC) architecture and a Don&amp;#8217;t Repeat Yourself (DRY) philosophy so your code is cleaner and easier to maintain. It also includes a object-relation mapping so that it is easy to store and retrieve stuff without having to write a bunch of low level &lt;span class="caps"&gt;SQL&lt;/span&gt;. It also handles sessions and uses a lot of conventions over configuration, which lets you get down to work rather than spending a lot of time setting stuff up.&lt;/p&gt;


	&lt;p&gt;It is always hard to learn a new language &lt;span class="caps"&gt;AND&lt;/span&gt; a new framework, but it is amazing how much we were able to accomplish in a short time starting at zero.&lt;/p&gt;


	&lt;p&gt;Another indication of how easy it is to develop applications in RoR is that even though it has only been around for about a year and a half, there are already an incredible amount of &lt;a href="http://rubyforge.org/softwaremap/trove_list.php?form_cat=312"&gt;applications&lt;/a&gt; available using it, including blogs, wikis, bug tracking, project tracking, accounting, forums, picture galleries, and more. For comparison, Java has been around for over 10 years, and it still doesn&amp;#8217;t have some of the applications available in RoR!&lt;/p&gt;</description>
      <pubDate>Sat, 03 Dec 2005 11:32:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:2c4db0d3119eedb79abd5cae96a946c9</guid>
      <author>Max Dunn</author>
      <link>http://blog.maxdunn.com/articles/2005/12/03/ruby-on-rails</link>
      <category>Ruby on Rails</category>
    </item>
  </channel>
</rss>
