Skip to content

Instantly share code, notes, and snippets.

@alex-zige
Created January 7, 2014 03:04
Show Gist options
  • Save alex-zige/8294060 to your computer and use it in GitHub Desktop.
Save alex-zige/8294060 to your computer and use it in GitHub Desktop.
Shell script for one-command bootstrap rails 4 project with ruby 2.0.0. [4.0.2] latest version. Please put the code into your ~/.bash_profile and call bootstrap_rails4 in terminal inside your target folder
function set_ruby2_with_gemset(){
local result=${PWD##*/}
local result=${result// /_}
local result=$(echo $result | tr '[A-Z]' '[a-z]')
echo "prepare ruby 2.0 with gemset "$result
rvm --create ruby-2.0.0-p247@$result
}
function use_ruby2_with_gemset(){
local result=${PWD##*/}
local result=${result// /_}
local result=$(echo $result | tr '[A-Z]' '[a-z]')
echo "use ruby 2.0 with gemset "$result
rvm use ruby-2.0.0-p247@$result
}
function bootstrap_rails4(){
echo "setting up ruby environment and gemset" &&
set_ruby2_with_gemset
wait
echo "install rails 4.0.2 version, this may take a while" &&
gem install rails -v 4.0.2
wait
echo "initialize rails project into current dir" &&
rails new .
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment