Skip to content

Instantly share code, notes, and snippets.

@rcmoret
Created September 15, 2016 22:26
Show Gist options
  • Save rcmoret/6d232b708fb2d45be86a8e01e46e17aa to your computer and use it in GitHub Desktop.
Save rcmoret/6d232b708fb2d45be86a8e01e46e17aa to your computer and use it in GitHub Desktop.
Script for opening a rails console for an app within vagrant
#! /bin/bash
if [[ -z $1 ]]; then
APP_NAME=$(basename `pwd`)
else
APP_NAME=$1
fi
echo "Opening Rails Console for $APP_NAME in vagrant..."
cd ~/vagrant && vagrant ssh -c "cd /pub/$APP_NAME/current && bundle exec rails console"
@AlexMooney
Copy link

This should drop you back out if you typo the app_name, rather than leave you sitting in the VM: vagrant ssh -c "cd /pub/$APP_NAME/current || exit; bundle exec rails console"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment