Subhashmohan's Blog

Edge Rails

Posted on: June 29, 2009

Before you get to know how to install and use Edge Rails, you need to know what actually Edge Rails is.

Edge Rails actually means running a local developmental version of rails. It’s an alternative to gem rails.

Many a times I have thought how to freeze my rails application to local gems version or a particular gems version, So that I can run my frozen application on some other system which have some different version of rails installed. Luckily I found Edge Rails.

For example:- Consider you have frozen your rails application to the latest rails version 2.3.2 and you want to run this application on a different system which have a much older version of rails, consider for example version 2.1.0.

In this case you can run your newest frozen version of rails application on  other system, which have an older version of rails installed, without any glitches or bugs, using Edge Rails.

How to Install and Use Edge Rails?

1.  If you want to freeze your application to the gems version currently available on your system, then go to root of your rails application and run

rake rails:freeze:gems

By running the above command a new directory “rails” will be created inside your vendors directory. When you run your rails framework, Your application will first check for this directory and if it’s present, Rails components will be loaded from this directory instead of using your system copy of rails, and thus you are switched from Gems Rails to Edge Rails.

2.  If at any point of time, you want to switch back from Edge Rails to Gem Rails. You can always do it by running the below command

rake rails:unfreeze

3. If you want to freeze your application to the latest development version, then run.

rake rails:freeze:edge

once you are switched to the latest development version, your javascripts and other configuration files needs to be updated corresponding to the latest version. For this you need to run,

rake rails:update

4. Freeze your application to a different version.
Consider you want to freeze your rails application to rails version 2.1.0, then you have to just run the command

rake rails:freeze:edge RELEASE=2.1.0

5. In order to find out what version of rails your application uses, From the  root of your rails application, run

script/about

your output will be something like below.

About your application’s environment
Ruby version              1.8.6 (i686-linux)
RubyGems version          1.1.1
Rails version             2.1.0
Active Record version     2.1.0
Action Pack version       2.1.0
Active Resource version   2.1.0
Action Mailer version     2.1.0
Active Support version    2.1.0
Edge Rails revision       unknown
Application root          your application path
Environment               development
Database adapter          mysql
Database schema version   20090622125330
Loaded suite script/about
Started

Finished in 0.000606 seconds.

0 tests, 0 assertions, 0 failures, 0 errors

6. Installing all other application depending gems locally.

1. Consider your application require the following two gems

a) will_paginate
b) mini_magick

Now go to your config/environment.rb file and config the required gems  as  below.

Rails::Initializer.run do |config|
config.gem “mini_magick”
config.gem “will_paginate”
end

2. Now consider these gems are not yet installed in your local machine. In order to install the above gems in your local machine,  from the root of your application run

rake gems:install

If you have already installed the above gems at some point of time, then skip this step and proceed to next step.

3. Now In order to make the above gems application-dependent rather than system-dependent gems. You need to unpack all these gems inside your application using

rake gems:unpack

The above command will create a new directory “gems” inside your vendor folder and unpack the two gems “will_paginate” and “mini_magick” inside the “gems” directory.

4. Unpack gems individually

There are two ways to unpack the gems individually.

Either run this from the root of your application.

rake gems:unpack GEM=will_paginate

or

change your directory to /vendor/gems and run

gem unpack “gem_name”

4. Freeze your application to a different version.Consider you want to freeze your rails application to rails version 2.1.0, then you have to just run the command

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog Stats

  • 3,807 hits
June 2009
M T W T F S S
    Mar »
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

Pages

%d bloggers like this: