How to create an empty Rails Edge application

January 28, 2009

As I wanted to start using the Rails 2.3+ application template feature, I needed a script able to create an empty Rails edge application.

Here it is packaged as a reusable Ruby script:

#!/usr/local/bin/ruby

require 'fileutils'

def launch(cmd)
  puts cmd
  throw "Error!" unless system(cmd)
end

abort "Syntax: my_rails app_name" unless (app_name = ARGV.first)
abort "Folder #{app_name} already there!" if File.exists?(app_name)

launch "mkdir -p #{app_name}/vendor" 

FileUtils.chdir app_name
launch "git clone git://github.com/rails/rails.git vendor/rails" 
launch "ruby vendor/rails/railties/bin/rails ." 
FileUtils.chdir '..'