addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1launch-new-window--smalllight-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Re: [ruby-81] Rails 1.2.6 and 2.x co-existing on a Windows box?

From: Chad W.
Sent on: Thursday, April 17, 2008 5:28 PM
On Thu, Apr 17, 2008 at 7:50 AM, Jon Seidel <[address removed]> wrote:
> I'm running InstantRails on a windows box (Rails 1.2.6).  I'm considering
> installing Rails 2.x for some testing I need to do (OpenLaszlo requires
> Rails 2.0) but I need to keep 1.2.6 for my other stuff.
> On Linux this would be easy, but I'm not sure how to make this happen on a
> Windoze box.

Do you want to switch rails versions for DIFFERENT apps?  If so, you
can just set the RAILS_GEM_VERSION in environment.rb for each app and
install both gems.

If you want to easily switch rails versions for the SAME app, here's
how you can do it:

In the boot.rb for Rails 2.0, you can add logic to
config/preinitialize­r.rb to issue the proper "gem('rails',version­)"
command, based on the RAILS_GEM_VERSION environment variable.  Don't
freeze anything, and don't set RAILS_GEM_VERSION in your

Then, you can just set the environment variable to pick which Rails
gem you want to use, without changing your app or freezing anything.
Some would say it is a good practice to use this approach to never
vendor your Rails :)

The nice thing is that the 2.0 boot.rb is completely backward
compatible AFAIK (and there were several buggy versions of boot.rb
prior to 2.0).  That means you can just paste in a Rails 2 version of
boot.rb (from a dummy generated app) to your 1.2.x app, create
config/preinitialize­r.rb, and you are set.

Explicitly managing all your dependency Gem versions (including rails
itself) is a good thing, and I created the GemInstaller tool [1] to
support this.  I also have a sample rails app [2] which shows how to
use the RAILS_GEM_VERSION env var trick [3] in the context of
GemInstaller.  Sorry, I haven't updated the GemInstaller docs [4] to
reflect the new preinitiailzer stuff yet.

I have used this approach with success on multiple projects.  It is
especially useful when you want to use Continuous Integration to test
your app or plugin against multiple versions of rails for completely
automated backward- or forward- compatibility assurance (which you
cannot easily do if you freeze Rails).

Let me know if you have questions.

Good luck!
-- Chad

[1] http://geminstall...­
[2] http://geminstall...­
[3] http://geminstall...­
[4] http://geminstall...­

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy