<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.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>schuerrer.org Weblog: Tag rails</title>
    <link>http://blog.schuerrer.org/articles/tag/rails</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Martin Schuerrer's perspective</description>
    <item>
      <title>F still comes before S</title>
      <description>&lt;p&gt;Some time ago &lt;a href="http://www.karmiccoding.com/pages/about"&gt;David Felstead&lt;/a&gt;, a &lt;em&gt;senior &lt;a href="http://www.site5.com"&gt;Site5&lt;/a&gt; engineer&lt;/em&gt;, said that Site5 was &lt;a href="http://www.karmiccoding.com/articles/2005/09/23/s-is-the-new-f-let-the-age-of-scgi-rails-begin"&gt;considering switching from FastCGI to &lt;span class="caps"&gt;SCGI&lt;/span&gt;&lt;/a&gt; and so I decided that if Site5 was considering it, I could simply do it.&lt;/p&gt;


He wrote about some major pains in the proverbial with FastCGI:
	&lt;ul&gt;
	&lt;li&gt;It&amp;#8217;s hard to set up&lt;/li&gt;
		&lt;li&gt;It&amp;#8217;s hard to monitor&lt;/li&gt;
		&lt;li&gt;It requires dedicated tasks to keep working (reaper, spawner, spinner anyone?)&lt;/li&gt;
		&lt;li&gt;Currently no one is actively developing the Apache module.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;According to him &lt;span class="caps"&gt;SCGI&lt;/span&gt; is better, because it only took him 15 minutes to set up properly. And now for the &lt;strong&gt;but&lt;/strong&gt;:&lt;/p&gt;


	&lt;p&gt;As you, dear well informed reader, of course know one feature of FastCGI is to keep &lt;em&gt;multiple&lt;/em&gt; instances of the Rails dispatcher open. &lt;span class="caps"&gt;SCGI&lt;/span&gt; in combination with the Apache module supports exactly &lt;em&gt;one&lt;/em&gt; instance of the dispatcher. There is &lt;a href="http://article.gmane.org/gmane.comp.lang.ruby.rails/33836"&gt;one obscure and in reality impossible way of changing that&lt;/a&gt; but believe me you don&amp;#8217;t want to do this.&lt;/p&gt;


	&lt;p&gt;For me monitoring seemed easier because &lt;a href="http://wiki.rubyonrails.com/rails/pages/LighttpdWithProcessScripts"&gt;reaper, spawner and spinner&lt;/a&gt; already exist for FastCGI opposed to my self-written Ruby script that tries to do the same for &lt;span class="caps"&gt;SCGI&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;And if that wouldn&amp;#8217;t be enough &lt;span class="caps"&gt;SCGI&lt;/span&gt; also simply delegates every request below a defined path to Rails, which of course sucks if you have static content in your application. You can try to work around that, but once you generate .js or .css files through Rails, you pretty much start hating &lt;span class="caps"&gt;SCGI&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;But uninformed as I was, I just went ahead and let &lt;span class="caps"&gt;SCGI&lt;/span&gt; handle my requests. Till today. Today I made &lt;a href="http://inlet-media.de/the-perfect-ruby-on-rails-with-apache2-and-fastcgi-setup-on-debian-sarge"&gt;Rails use FastCGI&lt;/a&gt;. I didn&amp;#8217;t exactly follow the instructions in that article, instead of compiling anything myself I just let apt and RubyGems do all the hard work:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;sudo apt-get install libfcgi-dev
sudo gem install fcgi&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;For me switching from &lt;span class="caps"&gt;SCGI&lt;/span&gt; to FastCGI brought nothing but relieve: My requests seem to get handled faster (probably because of the multiple instances running concurrently) and I no longer have to breach &lt;span class="caps"&gt;DRY&lt;/span&gt;, as my .htaccess doesn&amp;#8217;t need to exclude non all rails handled requests.&lt;/p&gt;
</description>
      <pubDate>Sat, 07 Jan 2006 21:24:00 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:84013910-a073-4e76-952c-a552613bf4d0</guid>
      <author>MSch</author>
      <link>http://blog.schuerrer.org/articles/2006/01/07/f-still-comes-before-s</link>
      <category>rails</category>
      <category>apache</category>
      <category>fastcgi</category>
      <trackback:ping>http://blog.schuerrer.org/articles/trackback/17</trackback:ping>
    </item>
    <item>
      <title>Convention over configuration</title>
      <description>&lt;a href="http://tech.rufy.com/"&gt;Lucas Carlson&lt;/a&gt; tried to &lt;a href="http://tech.rufy.com/entry/86"&gt;fix &lt;span class="caps"&gt;ERB&lt;/span&gt;&amp;#8217;s html_escape to escape special characters&lt;/a&gt;, because he didn&amp;#8217;t like that Rails produced &lt;input type="button" value="&amp;amp;lt; Back" /&gt; instead of &lt;input type="button" value="&amp;lt; Back" /&gt; with this statement:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;button_to&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;&amp;amp;lt; Back&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="symbol"&gt;:action&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;view&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="symbol"&gt;:id&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="number"&gt;3&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
So he went on and patched &lt;span class="caps"&gt;ERB&lt;/span&gt; so that it supported escaping of ampersands (by prefixing them with a \) and till yesterday that seemed like the Ruby like solution to my. But then I woke up today and everything seemed clear.

	&lt;p&gt;I was a fool. Not only did I completely ignore the potential security breach (&lt;a href="http://en.wikipedia.org/wiki/XSS"&gt;&lt;span class="caps"&gt;XSS&lt;/span&gt;&lt;/a&gt;) that was introduced by essentially removing html_escape&amp;#8217;s teeth, but I also neglected to see the really Rails like solution.&lt;/p&gt;


Rails is based on many principles that sound like buzzwords, but in fact aren&amp;#8217;t. &lt;strong&gt;Convention over configuration&lt;/strong&gt; is one of them, and it means that there&amp;#8217;s always one favoured way to do something. And for his problem this way is replacing the &lt;em&gt;&amp;amp;lt;&lt;/em&gt; with a plain old &lt;em&gt;&amp;lt;&lt;/em&gt;:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;button_to&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;&amp;lt; Back&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="symbol"&gt;:action&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;view&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="symbol"&gt;:id&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="number"&gt;3&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
</description>
      <pubDate>Sat, 17 Dec 2005 13:31:00 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:0680bc6f-657c-4a0d-8c6b-929a356cdac9</guid>
      <author>MSch</author>
      <link>http://blog.schuerrer.org/articles/2005/12/17/convention-over-configuration</link>
      <category>rails</category>
      <trackback:ping>http://blog.schuerrer.org/articles/trackback/7</trackback:ping>
    </item>
    <item>
      <title>How I updated my typo installation</title>
      <description>&lt;p&gt;Yesterday I went from some revision I never cared to remember to the new and shiny 762. But not everything went smooth. While the &lt;em&gt;svn update&lt;/em&gt; worked perfectly, the migrations simpley kept on failing. I even considered looking at the &lt;span class="caps"&gt;SQL&lt;/span&gt; for myself, but thankfully I rerun them once again, and voila, everything worked. This is a &lt;a href="http://typo.leetsoft.com/trac/ticket/594"&gt;&lt;strong&gt;documented bug&lt;/strong&gt;&lt;/a&gt;, but no fix is available as of now and why my &amp;#8220;solution&amp;#8221; worked is incomprehensible to me. (Also, I didn&amp;#8217;t investigate)&lt;/p&gt;


	&lt;p&gt;In other news: Typo has lots of &lt;a href="http://typo.leetsoft.com/trac/ticket/405"&gt;javascript problems&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Even considering all these bugs &lt;a href="http://typo.leetsoft.com"&gt;Typo&lt;/a&gt; is still the best blogging software around (not only because it&amp;#8217;s written in Rails) and I&amp;#8217;ll happily keep on playing beta testing guinea pig.&lt;/p&gt;
</description>
      <pubDate>Fri, 16 Dec 2005 17:43:00 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:4ba6f393-dce6-4372-95f3-e6ed2fa3a125</guid>
      <author>MSch</author>
      <link>http://blog.schuerrer.org/articles/2005/12/16/how-i-updated-my-typo-installation</link>
      <category>rails</category>
      <category>typo</category>
      <trackback:ping>http://blog.schuerrer.org/articles/trackback/5</trackback:ping>
    </item>
  </channel>
</rss>
