Viewing Posts from March, 2008

Downgrading Ruby on Rails

    

        Well, now that the new version of ruby on rails is out(2.0.2), everything should be new and improved. I do like a lot of things in the new version of rails but many of my apps are written in previous versions(like 1.2.6) and I'd like to keep them that way, for now. Rails 2.x is pretty good, but it's missing a lot of old rails core commands(like the old rest-less script/generate scaffold), that I happen to use sometimes. Also, a lot of people deploy rails applications in shared hosting environments and other places where they don't have the permissions to reinstall old versions of rails via gem, so here's an alternative. Here we will actually freeze the older version of rails to our application. In this example, I'll be downgrading ruby on rails 2.0.2 to 1.2.6. 

First, create a new rails application(we'll call it app):

     $ rails app

Then, cd into the directory:

     $ cd app

Now we will download the version of rails you want(here we will grab 1.2.6, but you can get any version) from the rails archive:

Note: you can do this a couple of different ways, this is using svn

     $ svn co http://dev.rubyonrails.org/svn/rails/tags/rel_1-2-6/

Copy and rename the downloaded folder to vendor/rails: 

     $ mv rel_1-2-6/ vendor/rails

Note: Rails looks automatically for a vendor/rails folder before using the server-wide ruby on rails libraries(aka gems). Having them stored this way is called "freezing" your gems.

Now all we have to do is replace the 2.0.2 version of  config/environment.rb file with a copy of the 1.2.6 version:  

     $ mv config/environment.rb config/environment.rb.original

     $ nano -w config/environment.rb

Here I'm using the linux text editor, nano. You can also use emacs, vi, notepad, textpad, or whatever you want. Basically, we're going to create a new empty file named config/environment.rb and paste this code into it:

ENV['RAILS_ENV'] ||= 'development'
RAILS_GEM_VERSION = '1.2.6'

require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
  config.action_controller.perform_caching = true
end

If you used the nano command(which I am using in this example), you can save the file by pressing CTRL + O(hold down the ctrl key and hit O), and then CTRL + X. 

That's it! You can now confirm that your using rails 1.2.6 by running this command:

      $ script/about

 You should see the version of rails now being 1.2.6, like so: 

About your application's environment
Ruby version                     1.8.6 (x86_64-linux)
RubyGems version             1.0.1
Rails version                            1.2.6
Active Record version          1.15.6
Action Pack version             1.13.6
Action Web Service version  1.2.6
Action Mailer version           1.3.6
Active Support version         1.4.4
Edge Rails revision             8976
Application root                  /home/bob/app
Environment                      development
Database adapter              mysql

 

 


Comment_add  (1) Comments




Powered_by_amethyst
Archive
Search
Tags
          Databases (1)
          General (2)
          Hosting (1)
          Hulihan Applications (3)
          Programming (1)
          Ruby (2)
          Ruby on Rails (6)
          Servers (1)
          Software (2)
view rss feed
This site is best displayed in FireFox 1.5+, IE 7+, and Opera 9+