Running is therapy

a blog about running, cats, Linux and programming.
  • Home
  • Current Schedule
  • Personal Records
  • Upcoming Races

Use a specific Rails version during project creation

Published by Nathan Powell on August 24, 2008 10:01 am under programming

If you do any amount of Rails programming, at some point you end up with various versions of Rails installed on your system. Generally this is fine as Rails keeps what version should be used in it’s environment.rb file.

However when you are creating a new project, the system rails command will use the most recent gem installed.

Also usually fine unless you know the latest version breaks something you want to use. Andy had mentioned to me before that it was possible to specify the version Rails should use on the command line when generating the initial project. However I forgot what it was. Lately I have been on a code reading kick so I decided to start at the start and see if I could remember what he had told me.

Well it didn’t take long. The 3rd line of actual code in the system `rails` command is:


if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then

You can see, if you specify:

rails _2.0.2_ project_name

And that particular Rails version is correct and installed, it will use that version. Thanks to Andy for pointing that out.

1 Comment so far

  1. Luke Francl on August 24th, 2008

    This trick works with a lot of gem-installed commands.

    For example, if you have Capistrano 1.4.1 and 2.x installed, the Cap2 version will be what’s run when you type `cap`. But you can use the old version by typing `cap _1.4.1_`. Pretty nice if you’ve got old apps still using Capistrano 1!

Posting your comment.

  • Search

  • Archives

    • November 2008 (1)
    • October 2008 (10)
    • September 2008 (4)
    • August 2008 (10)
    • July 2008 (11)
    • June 2008 (14)
    • May 2008 (15)
    • April 2008 (10)
    • March 2008 (16)
    • February 2008 (17)
    • January 2008 (37)
    • December 2007 (21)
    • November 2007 (30)
    • October 2007 (29)
    • September 2007 (22)
    • August 2007 (30)
    • July 2007 (49)
    • June 2007 (32)
    • May 2007 (29)
    • April 2007 (38)
    • March 2007 (26)
    • February 2007 (25)
    • January 2007 (23)
    • December 2006 (10)
    • November 2006 (12)
    • October 2006 (9)
    • September 2006 (9)
    • August 2006 (5)
    • July 2006 (13)
    • June 2006 (9)
    • May 2006 (8)
    • April 2006 (11)
    • March 2006 (12)
    • February 2006 (12)
    • January 2006 (13)
    • December 2005 (15)
    • November 2005 (19)
    • October 2005 (8)
  • Categories

    • blather (64)
    • books (10)
    • computers (177)
    • cooking (1)
    • economics (3)
    • emacs (3)
    • football (1)
    • gaming (1)
    • hiking (5)
    • housekeeping (5)
    • lifehacking (7)
    • music (3)
    • paddling (2)
    • personal (1)
    • politics (21)
    • programming (71)
    • running (236)
    • smoking (40)
    • sysadmin (11)
    • tlc (10)
    • Uncategorized (1)
  • Pages

    • Current Schedule
    • Personal Records
    • Upcoming Races

Copyright © 2008 Running is therapy
WordPress Theme based on Light Theme