Skip to content

Instantly share code, notes, and snippets.

@mikldt
Created February 24, 2010 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mikldt/313946 to your computer and use it in GitHub Desktop.
Save mikldt/313946 to your computer and use it in GitHub Desktop.

This is a new version file /usr/bin/rails generated on my system by installing the Rails 3 Gem. The problem with this executable is that the ‘rails’ command no longer provided a way to execute the executables from Rails 2, because the bin had moved from Rails to Railties. A few more details in the related blog post.

Call a version of Rails 2 like so (after putting the following code in /usr/bin/rails):

rails _2.3.5_ myapp

The second file can be put in /usr/bin/rails2 as a convenience path to run the latest available Rails 2 version easily.

rails2 myrails2app

#!/usr/bin/ruby1.8
#
# This file was generated by RubyGems, then edited for Rails 2
# backwards compatibility.
#
# The application 'railties' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
rails_gem = "railties"
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end
if version =~ /^2.*$/
rails_gem = "rails"
end
gem rails_gem, version
load Gem.bin_path(rails_gem, 'rails', version)
#!/usr/bin/ruby1.8
#
# This file should be run to run the 'rails' command from the
# rails 2 gem.
#
# The application 'rails' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = "< 3.0.0.beta"
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end
gem 'rails', version
load Gem.bin_path('rails', 'rails', version)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment