<?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>Drinkingbird: Category Ruby on Rails</title>
    <link>http://www.drinkingbird.net/blog/articles/category/ruby-on-rails</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Random keyboard peckings</description>
    <item>
      <title>ActiveRecord Reflective Validation</title>
      <description>&lt;p&gt;So, this is a pretty basic &amp;#8220;for work&amp;#8221; thing I ran into.&lt;/p&gt;

&lt;p&gt;Managers like forms with little red asterisks next to required fields, and there doesn&amp;#8217;t seem to be any straightforward way to query an ActiveRecord class to determine which fields are required.&lt;/p&gt;

&lt;p&gt;Since AR already has to perform the validation, it seemed only right to lump it with the responsibility of keeping track of its own details.&lt;/p&gt;

&lt;p&gt;So far, I&amp;#8217;ve knocked up a small plugin within an existing rails app, which currently deals with presence and uniqueness validations, by providing the methods:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;validates_presence_of?(field)&lt;/li&gt;
&lt;li&gt;validates_uniqueness_of?(field)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;to inspect the model classes.&lt;/p&gt;

&lt;p&gt;Without further ado, here&amp;#8217;s the prototype code:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="keyword"&gt;module &lt;/span&gt;&lt;span class="module"&gt;ActiveRecord&lt;/span&gt;
  &lt;span class="keyword"&gt;module &lt;/span&gt;&lt;span class="module"&gt;ReflectiveValidation&lt;/span&gt;
    &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;self.included&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;mod&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
      &lt;span class="ident"&gt;mod&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;extend&lt;/span&gt; &lt;span class="constant"&gt;ClassMethods&lt;/span&gt;
      &lt;span class="ident"&gt;validation_methods&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;each&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;method&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt;
        &lt;span class="ident"&gt;arr_name&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&lt;span class="expr"&gt;#{method}&lt;/span&gt;_fields&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;.&lt;/span&gt;&lt;span class="ident"&gt;to_sym&lt;/span&gt;
        &lt;span class="ident"&gt;mod&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;class_inheritable_array&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;arr_name&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
        &lt;span class="ident"&gt;mod&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;write_inheritable_array&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;arr_name&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="punct"&gt;[])&lt;/span&gt;
      &lt;span class="keyword"&gt;end&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt;

    &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;self.validation_methods&lt;/span&gt;
      &lt;span class="punct"&gt;[&lt;/span&gt;
        &lt;span class="symbol"&gt;:validates_presence_of&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt;
        &lt;span class="symbol"&gt;:validates_uniqueness_of&lt;/span&gt;
      &lt;span class="punct"&gt;]&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt;
    &lt;span class="keyword"&gt;module &lt;/span&gt;&lt;span class="module"&gt;ClassMethods&lt;/span&gt;
      &lt;span class="constant"&gt;ActiveRecord&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;ReflectiveValidation&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="ident"&gt;validation_methods&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;each&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;method&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt;
        &lt;span class="ident"&gt;module_eval&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;
          &lt;span class="punct"&gt;&amp;lt;&amp;lt;-&lt;/span&gt;&lt;span class="constant"&gt;eos&lt;/span&gt;&lt;span class="string"&gt;
            def &lt;span class="expr"&gt;#{method}&lt;/span&gt;(*fields)
              write_inheritable_array(:&lt;span class="expr"&gt;#{method}&lt;/span&gt;_fields, fields)
              super(fields)
            end

            def &lt;span class="expr"&gt;#{method}&lt;/span&gt;?(field)
              &lt;span class="expr"&gt;#{method}&lt;/span&gt;_fields.include?(field)
            end
&lt;/span&gt;&lt;span class="constant"&gt;          eos&lt;/span&gt;
        &lt;span class="punct"&gt;)&lt;/span&gt;
      &lt;span class="keyword"&gt;end&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I&amp;#8217;m looking at fleshing it out, handling more validations, and hopefully dealing with things like length requirements.&lt;/p&gt;

&lt;p&gt;Oh, and actually hosting the plugin somewhere.&lt;/p&gt;</description>
      <pubDate>Thu, 05 Jun 2008 01:55:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:c8e27c95-32c3-4144-b43a-f92ab68453aa</guid>
      <author>Chris</author>
      <link>http://www.drinkingbird.net/blog/articles/2008/06/05/activerecord-reflective-validation</link>
      <category>Ruby on Rails</category>
      <category>ActiveRecord</category>
      <category>ruby</category>
      <category>rails</category>
      <category>plugins</category>
    </item>
    <item>
      <title>Rails and shitty SQL generation</title>
      <description>&lt;p&gt;Just a quick bitch about something I came across in setting up &lt;a href="http://www.redmine.org"&gt;Redmine&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Removing members from a project in the admin interface was silently failing for me.&lt;/p&gt;

&lt;p&gt;It turns out that Redmine, rather sensibly, updates the project so that no issues are automatically assigned to the user being removed from the project. This makes a call to ActiveRecord::Base&amp;#8217;s update_all method.&lt;/p&gt;

&lt;p&gt;This was the call that was failing, and it was all down to the fact that ActiveRecord was passing my postgres database an update query with an &amp;#8220;ORDER BY&amp;#8221; clause, which is apparently the sort of fucking retarded feature that mysql decided to implement, and which some useless dick chose to support in AR.&lt;/p&gt;

&lt;p&gt;Really, what&amp;#8217;s the point of ordering your update statement?&lt;/p&gt;

&lt;p&gt;I don&amp;#8217;t know who to be more pissed off at over this, but given past experiences with mysql I&amp;#8217;ll pin it on them.&lt;/p&gt;

&lt;p&gt;FUCK YOU AGAIN, MYSQL!&lt;/p&gt;</description>
      <pubDate>Wed, 27 Feb 2008 20:57:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:5dca8a9e-ce67-4a53-8905-bfa1fb4cde02</guid>
      <author>Chris</author>
      <link>http://www.drinkingbird.net/blog/articles/2008/02/27/rails-and-shitty-sql-generation</link>
      <category>Ruby on Rails</category>
    </item>
    <item>
      <title>Setting up a Redmine site on Ubuntu</title>
      <description>&lt;p&gt;After a variety of headaches setting up a redmine instance on an Ubuntu server, I thought I&amp;#8217;d write a quick guide on how to do it quickly.&lt;/p&gt;

&lt;h2&gt;First step&lt;/h2&gt;

&lt;p&gt;Install Ubuntu.
What flavour you go with is up to you.&lt;/p&gt;

&lt;h2&gt;Packages from apt&lt;/h2&gt;

&lt;h3&gt;Install packages&lt;/h3&gt;

&lt;p&gt;as root, run:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;aptitude install apache2 ruby rubygems subversion ruby-pkg-tools \
ruby1.8-dev build-essential postgresql libdbd-pg-perl libapache2-svn \
libapache-dbi-perl libapache2-mod-perl2 libdigest-sha1-perl&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If you want to go with mysql rather than postgres, you can drop the postgresql and libdbd-pg-perl packages, and install the mysql equivalents, but you&amp;#8217;re on your own in setting up the database.&lt;/p&gt;

&lt;h2&gt;Ruby gems&lt;/h2&gt;

&lt;h3&gt;Install gems&lt;/h3&gt;

&lt;p&gt;as root, run:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;gem install rails mongrel mongrel_cluster postgres-pr --include-dependencies&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Add gems to $PATH&lt;/h3&gt;

&lt;p&gt;I did this by adding the line:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;export PATH=/var/lib/gems/1.8/bin to the end of /etc/profile&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Set up the database for Redmine to use&lt;/h2&gt;

&lt;h3&gt;Switch to postgres user&lt;/h3&gt;

&lt;p&gt;as root, run:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;su postgres&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Create the redmine user&lt;/h3&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;createuser redmine --no-superuser --no-createdb --no-createrole --login --pwprompt --encrypted&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Create the redmine database&lt;/h3&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;createdb --owner=redmine --encoding=utf-8 redmine&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Switch back&lt;/h3&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;exit&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;For the tutorial, I&amp;#8217;ll be using the password &amp;#8220;redmine&amp;#8221; for the redmine user.&lt;/p&gt;

&lt;h2&gt;Redmine itself&lt;/h2&gt;

&lt;p&gt;For this setup I&amp;#8217;ll be using the 0.6 stable branch of redmine via svn, and installing it under /var/www/rails_apps/redmine-0.6&lt;/p&gt;

&lt;h3&gt;Create the directory and checkout Redmine&lt;/h3&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;mkdir /var/www/rails_apps
cd /var/www/rails_apps
svn co http://redmine.rubyforge.org/svn/branches/0.6-stable redmine-0.6&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Configure database access&lt;/h3&gt;

&lt;p&gt;Create the file config/database.yml within the redmine directory with the following contents:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_yaml "&gt;&lt;span class="key"&gt;production&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt;
  &lt;span class="key"&gt;adapter&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; postgresql
  &lt;span class="key"&gt;database&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; redmine
  &lt;span class="key"&gt;host&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; localhost
  &lt;span class="key"&gt;username&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; redmine
  &lt;span class="key"&gt;password&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; redmine&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Bootstrap the database&lt;/h3&gt;

&lt;p&gt;In the Redmine directory, run:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;rake db:migrate RAILS_ENV=&amp;quot;production&amp;quot;
rake redmine:load_default_data RAILS_ENV=&amp;quot;production&amp;quot;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Configure mailing from Redmine&lt;/h3&gt;

&lt;p&gt;Setting up a mail account for redmine is your own business, then change this section of config/environment.rb:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="comment"&gt;# SMTP server configuration&lt;/span&gt;
&lt;span class="ident"&gt;config&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;action_mailer&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;smtp_settings&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;{&lt;/span&gt;
  &lt;span class="symbol"&gt;:address&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;127.0.0.1&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt;
  &lt;span class="symbol"&gt;:port&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="number"&gt;25&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt;
  &lt;span class="symbol"&gt;:domain&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;somenet.foo&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt;
  &lt;span class="symbol"&gt;:authentication&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="symbol"&gt;:login&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt;
  &lt;span class="symbol"&gt;:user_name&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;redmine&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt;
  &lt;span class="symbol"&gt;:password&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;redmine&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt;
&lt;span class="punct"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;to this:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="comment"&gt;# SMTP server configuration&lt;/span&gt;
&lt;span class="ident"&gt;config&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;action_mailer&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;smtp_settings&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;{&lt;/span&gt;
  &lt;span class="symbol"&gt;:address&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;mail.yourdomain.com&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt;
  &lt;span class="symbol"&gt;:port&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="number"&gt;25&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt;
  &lt;span class="symbol"&gt;:domain&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;yourdomain.com&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt;
  &lt;span class="symbol"&gt;:authentication&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="symbol"&gt;:login&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt;
  &lt;span class="symbol"&gt;:user_name&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;mail_user&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt;
  &lt;span class="symbol"&gt;:password&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;mail_password&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
&lt;span class="punct"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;or whatever&amp;#8217;s appropriate for your setup.&lt;/p&gt;

&lt;h3&gt;Check that everything&amp;#8217;s set up correctly&lt;/h3&gt;

&lt;p&gt;From the redmine directory run:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;mongrel_rails start --environment=production&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You should be able to view the redmine site at localhost:3000 and log in using the username &amp;#8220;admin&amp;#8221; and password &amp;#8220;admin&amp;#8221;.&lt;/p&gt;

&lt;h2&gt;Setting up subversion&lt;/h2&gt;

&lt;h3&gt;Create the repository location&lt;/h3&gt;

&lt;p&gt;as root:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;mkdir /var/svn
chmod 0750 /var/svn&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Serve the repository path through Apache&lt;/h3&gt;

&lt;h4&gt;Enable the necessary Apache modules&lt;/h4&gt;

&lt;p&gt;as root:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;a2enmod dav
a2enmod dav_svn
a2enmod perl&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h4&gt;Configure site and delegate authentication to Redmine&lt;/h4&gt;

&lt;p&gt;Copy the file Redmine.pm from the extra/svn directory in Redmine to /usr/lib/apache2.&lt;/p&gt;

&lt;p&gt;Create a file under /etc/apache2/sites-available with an appropriate name (e.g. svn.yourdomain) with the following contents:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;&amp;lt;VirtualHost *&amp;gt;
  ServerAdmin support@yourdomain
  ServerName svn.yourdomain

  PerlRequire /usr/lib/apache2/Redmine.pm

  &amp;lt;Location /svn&amp;gt;
    DAV svn
    SVNParentPath &amp;quot;/var/svn&amp;quot;

    AuthType Basic
    Authname &amp;quot;Redmine Project Tracking&amp;quot;
    Require valid-user

    PerlAccessHandler Apache::Authn::Redmine::access_handler
    PerlAuthenHandler Apache::Authn::Redmine::authen_handler
    PerlSetVar dsn DBI:Pg:dbname=redmine;host=localhost
    PerlSetVar db_user redmine
    PerlSetVar db_pass redmine
  &amp;lt;/Location&amp;gt;

&amp;lt;/VirtualHost&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Enable the site and restart apache:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;ln -s /etc/apache2/sites-available/svn.yourdomain /etc/apache2/sites-enabled/svn.yourdomain
    /etc/init.d/apache2 restart&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h4&gt;Check it&amp;#8217;s up&lt;/h4&gt;

&lt;p&gt;Now, if you point your browser to http://svn.yourdomain/svn you should be prompted for a username and password. Don&amp;#8217;t worry about authenticating yet, that&amp;#8217;s for when you actually have a project repository to go poking around in.&lt;/p&gt;

&lt;h2&gt;Serve Redmine through apache and mongrel_cluster&lt;/h2&gt;

&lt;h3&gt;Set up the cluster&lt;/h3&gt;

&lt;p&gt;Create the file config/mongrel_cluster.yml under the Redmine directory with the following contents:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_yaml "&gt;&lt;span class="key"&gt;user&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; root
&lt;span class="key"&gt;cwd&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; /var/www/rails_apps/redmine-0.6
&lt;span class="key"&gt;port&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;9000&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
&lt;span class="key"&gt;environment&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; production
&lt;span class="key"&gt;group&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; root
&lt;span class="key"&gt;address&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; 0.0.0.0
&lt;span class="key"&gt;pid_file&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; log/mongrel.pid
&lt;span class="key"&gt;servers&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; 2&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Check the cluster works&lt;/h3&gt;

&lt;p&gt;In the redmine directory, run:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;mongrel_rails cluster::start&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You should be able to get to Redmine on ports 9000 and 9001 of your server.&lt;/p&gt;

&lt;h3&gt;Have the cluster start at boot&lt;/h3&gt;

&lt;p&gt;As root:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;mkdir /etc/mongrel_cluster
ln -s /var/www/rails_apps/redmine-0.6/config/mongrel_cluster.yml /etc/mongrel_cluster/redmine.yml
cp /var/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.5/resources/mongrel_cluster /etc/init.d
chmod +x /etc/init.d/mongrel_cluster
/usr/sbin/update-rc.d -f mongrel_cluster defaults&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Install some more Apache modules&lt;/h3&gt;

&lt;p&gt;As root:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;a2enmod proxy
a2enmod proxy_http
a2enmod proxy_balancer
a2enmod rewrite&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Configure the redmine site through Apache&lt;/h3&gt;

&lt;p&gt;Create /etc/apache2/sites-available/redmine.yourdomain with the following contents:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;&amp;lt;VirtualHost *&amp;gt;

  ServerAdmin support@yourdomain
  DocumentRoot /var/www/rails_apps/redmine-0.6
  ServerName redmine.yourdomain
  ErrorLog /var/www/rails_apps/redmine-0.6/log/error.log

  ProxyPass /images !
  ProxyPass /stylesheets !
  ProxyPass /javascripts !
  ProxyPass /favicon.ico !
  ProxyPass /static !
  ProxyPass /holding !
  ProxyPass /templates !
  ProxyPass / balancer://redmine_cluster
  ProxyPreserveHost On

  &amp;lt;Proxy balancer://redmine_cluster&amp;gt;
    BalancerMember http://127.0.0.1:9000
    BalancerMember http://127.0.0.1:9001
  &amp;lt;/Proxy&amp;gt;

  RewriteEngine On
   # Redirect all non-static requests to cluster
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*)$ balancer://redmine_cluster%{REQUEST_URI} [P,QSA,L]
&amp;lt;/VirtualHost&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Enable the site and restart apache:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;ln -s /etc/apache2/sites-available/redmine.yourdomain /etc/apache2/sites-enabled/redmine.yourdomain
/etc/init.d/apache2 restart&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Have Redmine manage your repositories&lt;/h2&gt;

&lt;h3&gt;Tell Redmine that it&amp;#8217;s managing your repositories&lt;/h3&gt;

&lt;p&gt;In the Redmine site, go to Administration -&gt; Settings.
Tick the box labeled &amp;#8220;Enable WS for repository management&amp;#8221;&lt;/p&gt;

&lt;h3&gt;Set up automatic repository creation&lt;/h3&gt;

&lt;h4&gt;Check that repository autocreation works&lt;/h4&gt;

&lt;p&gt;Add a project through Redmine with the identifier &amp;#8220;test&amp;#8221;&lt;/p&gt;

&lt;p&gt;On your SVN server run:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;ruby /var/www/rails_apps/redmine-0.6/extra/svn/reposman.rb --redmine redmine.theoru.com --svn-dir /var/svn --owner www-data --url http://svn.theoru.com/svn/&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You should get the following message:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;repository /var/svn/test registered in Redmine with url http://svn.theoru.com/svn/test
repository /var/svn/test created&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h4&gt;Make the server do your dirty work for you&lt;/h4&gt;

&lt;p&gt;Add the following line to /etc/crontab:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;10 * * * * root ruby /var/www/rails_apps/redmine-0.6/extra/svn/reposman.rb --redmine redmine.yourdomain --svn-dir /var/svn --owner www-data --url http://svn.yourdomain/svn/&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h4&gt;Restrict access to Redmine&amp;#8217;s web services&amp;#8217; API&lt;/h4&gt;

&lt;p&gt;Add the following section to /etc/apache2/sites-available/redmine.yourdomain:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;&amp;lt;Location /sys&amp;gt;
  Order allow,deny
  Allow from ip.of.svn.yourdomain
&amp;lt;/Location&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Restart apache:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;/etc/init.d/apache2 restart&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Relax, it&amp;#8217;s done&lt;/h2&gt;

&lt;p&gt;Redmine and SVN should be happily up and running.&lt;/p&gt;

&lt;p&gt;Once an hour, the cron job you set up will check for any newly registered projects and create an SVN repository for each new project at http://svn.yourdomain/svn/#{project_identifier} and register this location with the project.&lt;/p&gt;

&lt;p&gt;To allow repository browsing, you will need to add appropriate credentials (e.g. project manager login) to the repository settings of the project.&lt;/p&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;</description>
      <pubDate>Wed, 27 Feb 2008 10:37:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:186de700-df84-4727-833f-109a5363f842</guid>
      <author>Chris</author>
      <link>http://www.drinkingbird.net/blog/articles/2008/02/27/setting-up-a-redmine-site-on-ubuntu</link>
      <category>Ruby on Rails</category>
      <category>redmine</category>
      <category>svn</category>
      <category>projects</category>
    </item>
    <item>
      <title>Disk free custom images on rails.</title>
      <description>&lt;p&gt;So, I hit an odd problem in one of the apps I&amp;#8217;m working on that I needed to render custom text onto images.&lt;/p&gt;

&lt;p&gt;RMagick made that job pretty easy, but I didn&amp;#8217;t want to clog up space on the server with a whole bunch of images that were only being viewed once.&lt;/p&gt;

&lt;p&gt;The solution turned out to be fairly simple in the end, using send_data in the controller.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ll let the code speak for itself:&lt;/p&gt;

&lt;p&gt;Controller (in StoreController):&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;gift_preview&lt;/span&gt;
  &lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;RMagick&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;

  &lt;span class="ident"&gt;text_params&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;{&lt;/span&gt;
    &lt;span class="symbol"&gt;:width&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="number"&gt;200&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt;
    &lt;span class="symbol"&gt;:height&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="number"&gt;120&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt;
    &lt;span class="symbol"&gt;:xpos&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="number"&gt;240&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt;
    &lt;span class="symbol"&gt;:ypos&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="number"&gt;340&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt;
    &lt;span class="symbol"&gt;:colour&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;black&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
  &lt;span class="punct"&gt;}&lt;/span&gt;

  &lt;span class="comment"&gt;# Get base image&lt;/span&gt;
  &lt;span class="ident"&gt;image&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;Magick&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;ImageList&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="constant"&gt;File&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;join&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&lt;span class="expr"&gt;#{RAILS_ROOT}&lt;/span&gt;/public/images&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;gift_box.jpg&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt;

  &lt;span class="comment"&gt;# Set up text&lt;/span&gt;
  &lt;span class="ident"&gt;text&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;Magick&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Draw&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt;
  &lt;span class="ident"&gt;text&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;font_family&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;times&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
  &lt;span class="ident"&gt;text&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;pointsize&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="number"&gt;15&lt;/span&gt;
  &lt;span class="ident"&gt;text&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;font_style&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;Magick&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;ItalicStyle&lt;/span&gt;

  &lt;span class="comment"&gt;# Add text to image&lt;/span&gt;
  &lt;span class="ident"&gt;text&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;annotate&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;
    &lt;span class="ident"&gt;image&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt;
    &lt;span class="ident"&gt;text_params&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:width&lt;/span&gt;&lt;span class="punct"&gt;],&lt;/span&gt;
    &lt;span class="ident"&gt;text_params&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:height&lt;/span&gt;&lt;span class="punct"&gt;],&lt;/span&gt;
    &lt;span class="ident"&gt;text_params&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:xpos&lt;/span&gt;&lt;span class="punct"&gt;],&lt;/span&gt;
    &lt;span class="ident"&gt;text_params&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:ypos&lt;/span&gt;&lt;span class="punct"&gt;],&lt;/span&gt;
    &lt;span class="ident"&gt;params&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:message&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="punct"&gt;{&lt;/span&gt;
    &lt;span class="constant"&gt;self&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;fill&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;text_params&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:colour&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt;
  &lt;span class="punct"&gt;}&lt;/span&gt;
  &lt;span class="comment"&gt;# send the image data back&lt;/span&gt;
  &lt;span class="ident"&gt;send_data&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="ident"&gt;image&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;to_blob&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="symbol"&gt;:type&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;image/jpeg&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The important part of this is the last line that sends the image back as a binary blob with an appropriate content type (adjust for your image format).&lt;/p&gt;

&lt;p&gt;In the template I have:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;&amp;lt;%= link_to_function &amp;quot;Gift Preview&amp;quot;,
  &amp;quot;$('gift_image').src='#{url_for( :action =&amp;gt; 'gift_preview' )}?message=' + $F('order_message')&amp;quot; %&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&amp;#8220;order_message&amp;#8221; is a text area, and $F is a very handy prototype function that grabs it&amp;#8217;s current contents, and &amp;#8220;gift_image&amp;#8221; is an image tag for displaying the custom image.&lt;/p&gt;

&lt;p&gt;Clicking on this link sets the image source to the gift_preview action, passing the current message, then the controller returns the new custom image, never writing it to disk.&lt;/p&gt;

&lt;p&gt;The code can do with some tidying, but for now, this is working for me (and it&amp;#8217;s a prototype, so :P).&lt;/p&gt;

&lt;p&gt;Enjoy! And for more RMagick detail, head &lt;a href="http://rmagick.rubyforge.org"&gt;here&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Wed, 05 Sep 2007 20:38:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:deb1fa78-4d2b-4786-b612-85710e71ced9</guid>
      <author>Chris</author>
      <link>http://www.drinkingbird.net/blog/articles/2007/09/05/disk-free-custom-images-on-rails</link>
      <category>Ruby on Rails</category>
    </item>
    <item>
      <title>Fix the Apache trailing slash problem</title>
      <description>&lt;p&gt;After a lot of stuffing about I finally found a solution to the problem that I was having with the URL for this blog.&lt;/p&gt;

&lt;p&gt;The basic problem was that the link http://www.drinkingbird.net/blog (without the trailing slash) was being rejected with a &lt;code&gt;400 Bad Request&lt;/code&gt; error.&lt;/p&gt;

&lt;p&gt;I spent ages trying to get this to work with awkward rewrite rules in the parent directory, when I should have been looking in the public directory of the rails app. The solution is well enough explained over at &lt;a href="http://www.lavafactory.com/articles/2006/09/27/how-to-fix-the-trailing-slash-problem-with-apache-rails"&gt;LavaFactory&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I just made one small refinement, which is to change:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;RewriteRule .*/blog/(.*) http://www.drinkingbird.net/blog/$1 [L,R]&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;to&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;RewriteRule (.*)/blog/(.*) $1/blog/$2&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;to satisfy my relentless desire to avoid configuration tied to a particular domain.&lt;/p&gt;</description>
      <pubDate>Sun, 17 Jun 2007 05:48:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:5f8e6bb8-4051-4087-92d6-cc9708c077ac</guid>
      <author>Chris</author>
      <link>http://www.drinkingbird.net/blog/articles/2007/06/17/fix-the-apache-trailing-slash-problem</link>
      <category>Typo</category>
      <category>Ruby on Rails</category>
    </item>
    <item>
      <title>Typo on Site5</title>
      <description>&lt;p&gt;I thought I&amp;#8217;d post a quick summary on what I went through to get Typo up and running on &lt;a href="http://www.site5.com"&gt;Site5&lt;/a&gt;, since it&amp;#8217;s a bit more tricky now that the SiteAdmin interface no longer contains an automatic install script.&lt;/p&gt;

&lt;p&gt;I decided to go the gem route on this, so that&amp;#8217;s the only way I&amp;#8217;m going to talk about. If you want to install from SVN trunk, you&amp;#8217;re on your own.&lt;/p&gt;

&lt;p&gt;First, you&amp;#8217;ll want to set up your account with a local gem installation directory, as detailed in this &lt;a href="http://forums.site5.com/showthread.php?t=11954"&gt;forum thread&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Then, ssh into your account (if you&amp;#8217;re not still there), and type:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;gem install typo&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;There&amp;#8217;s a good chance this will fail the first time, with an error on attempting to install the sqlite3-ruby gem. This can be solved by opening a ticket with Site5&amp;#8217;s support, and asking to have the sqlite-devel package installed on your server, then trying again.&lt;/p&gt;

&lt;p&gt;Once the gem is installed, you just need to run&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;typo &amp;lt;installation directory&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; then manually kill the mongrel process it spaws immediately after installation (I&amp;#8217;d lay money on site5&amp;#8217;s servers doing this automatically if you don&amp;#8217;t anyway).

From here, it&amp;#8217;s all fairly easy:

Edit the environment.rb file in typo&amp;#8217;s config directory, and uncomment the line:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="constant"&gt;ENV&lt;/span&gt;&lt;span class="punct"&gt;['&lt;/span&gt;&lt;span class="string"&gt;RAILS_ENV&lt;/span&gt;&lt;span class="punct"&gt;']&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;production&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;and add the line:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="constant"&gt;ENV&lt;/span&gt;&lt;span class="punct"&gt;['&lt;/span&gt;&lt;span class="string"&gt;GEM_PATH&lt;/span&gt;&lt;span class="punct"&gt;']&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;/home/&amp;lt;your_username&amp;gt;/&amp;lt;path_to_gems&amp;gt;:/usr/lib/ruby/gems/1.8&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Create the file public/.htaccess in the typo directory as:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;# General Apache options
AddHandler fastcgi-script .fcgi
Options +FollowSymLinks +ExecCGI

RewriteEngine On

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

ErrorDocument 500 /500.html # You may want to edit this file&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Setup a mysql database for the blog&amp;#8217;s production db, and configure it in config/database.yml. Example config:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_yaml "&gt;&lt;span class="key"&gt;production&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt;
  &lt;span class="key"&gt;adapter&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; mysql
  &lt;span class="key"&gt;database&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; username_blog
  &lt;span class="key"&gt;username&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; username_blog
  &lt;span class="key"&gt;password&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; secret
  &lt;span class="key"&gt;host&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; localhost&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Then run &lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;rake db:migrate RAILS_ENV=production&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;to load the schema.&lt;/p&gt;

&lt;p&gt;If you installed your blog anywhere other than under your public_html directory, you&amp;#8217;ll need to create a symlink to the blog, e.g.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;ln -s /path/to/typo/public public_html/blog&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Hopefully this ends up helping someone. If not, well at least it gave me an excuse to get to grips with some of typo&amp;#8217;s editing syntax. If I&amp;#8217;ve missed anything, please bitch at me, so I can fix it.&lt;/p&gt;</description>
      <pubDate>Sun, 10 Jun 2007 06:51:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:6d4ddb74-99b7-429e-b270-0433e34019e9</guid>
      <author>Chris</author>
      <link>http://www.drinkingbird.net/blog/articles/2007/06/10/typo-on-site5</link>
      <category>Typo</category>
      <category>Ruby on Rails</category>
    </item>
  </channel>
</rss>
