Skip to content

Instantly share code, notes, and snippets.

@ncuesta
Last active December 10, 2015 10:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ncuesta/4422630 to your computer and use it in GitHub Desktop.
Save ncuesta/4422630 to your computer and use it in GitHub Desktop.
Short script to keep an updated local copy of Ruby on Rails master branch and run commands using that version rather than a global stable version of the framework.
#!/bin/bash
# Keep an updated local copy of Ruby on Rails
# and use it to run commands, rather than the
# version you might have installed as a gem
# on your system
#
# @author ncuesta
# Customize this with your own fork
RAILS_REPO='https://github.com/rails/rails'
# Path to the local copy of Rails
LOCAL_RAILS=~/.rails-master
# Clone or update a local copy of Rails
if [ ! -d $LOCAL_RAILS ]; then
git clone $RAILS_REPO $LOCAL_RAILS
else
pushd $LOCAL_RAILS
git pull
popd
fi
# Try to run Rails with the given arguments
RAILS=$LOCAL_RAILS/railties/bin/rails
if [ -x $RAILS ]; then
$RAILS $*
else
echo "Unable to find Rails executable"
echo "(Tried at $RAILS)."
echo "Did the git clone end correctly?"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment