Ruby on Rails
Howto run a self contained rails app

Preamble

The reason I wrote this how-to is because a long time ago, I developed a rails application, which, for reasons I don’t want to get into, cannot run under rails versions higher than 0.12.1.

This application has been running just fine. However, it came the moment that I wanted to share the server with newer applications and rails version 1.0 and higher.

Simplified Solution

The simplest solution, as suggested by drd on IRC, is to copy the rails version to the vendor directory of your application. The initial suggestion was to use SVN to fetch the required version.

In my case, looking at http://dev.rubyonrails.org/svn/rails/tags/ showed that the particular version I needed (0.12.1) was not available through SVN.

I ended up fetching the .tgz file from http://rubyforge.org/frs/?group_id=307&release_id=3794 and expanding it in my vendor directory.

Please note that the .tgz file is a complete rails application folder. I actually expanded it to a temporary directory and then ONLY moved the vendor/rails folder from that temporary directory into the vendor directory of my actual application.

Ruby Version

While testing the application, I noticed that rails was not properly loading required dependencies. Looking through the rails code, I found references to checking the version of Ruby to be greater than or equal to 1.8.2. I am running version 1.8.4 which should be fine. However, it was not working.

As a work around, I found the culprit of the problem. I had to edit the file vendor/rails/activesupport/lib/active_support/clean_logger.rb and comment out the line that read remove_cost “Format”

Orginal vendor/rails/activesupport/lib/active_support/clean_logger.rb


require 'logger'

class Logger #:nodoc:
private
remove_const “Format”
Format = “%s\n”
def format_message(severity, timestamp, msg, progname)
Format % [msg]
end
end

Modified vendor/rails/activesupport/lib/active_support/clean_logger.rb


require 'logger'

class Logger #:nodoc:
private
#remove_const “Format”
Format = “%s\n”
def format_message(severity, timestamp, msg, progname)
Format % [msg]
end
end

Note again that this was rails 0.12.1. Other versions may have a different content.

Once the change was made, rails 0.12.1 ran perfectly under Ruby 1.8.4 in a self contained application folder.