Skip to content

Instantly share code, notes, and snippets.

@waiting-for-dev
Last active January 11, 2018 13:53
Show Gist options
  • Save waiting-for-dev/11495350 to your computer and use it in GitHub Desktop.
Save waiting-for-dev/11495350 to your computer and use it in GitHub Desktop.
function rails() {
if [ "$1" = "start" ]; then
if [ "$2" = "" ]; then
RENV="development"
else
RENV="$2"
fi
rails server -d -e "$RENV"
return 0
elif [ "$1" = "stop" ]; then
if [ -f tmp/pids/server.pid ]; then
kill $2 $(cat tmp/pids/server.pid)
return 0
else
echo "It seems there is no server running or you are not in a rails project root directory"
return 1
fi
elif [ "$1" = "restart" ]; then
rails stop && rails start $2
else
command rails $@
fi;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment