Ruby terminal commands and GitHub workflow

Setting up your development machine is a headache. Here’s a little bit of research.

Project Requirements

  1. Virtual Box
  2. Text Editor
  3. Vagrant

— — —


cd ~/Desktop/vagrant

Download vagrant files

$ vagrant up

Notes: This command creates and configures guest machines according to your Vagrantfile.

This is the single most important command in Vagrant, since it is how any Vagrant machine is created. Anyone using Vagrant must use this command on a day-to-day basis.

Launch your Web Dev environment

$ vagrant ssh

Notes: This will SSH into a running Vagrant machine and give you access to a shell.

On a simple vagrant project, the instance created will be named default.

Vagrant will ssh into this instance without the instance name:

$ vagrant ssh
Welcome to your Vagrant-built virtual machine.
Last login: Fri Sep 14 06:23:18 2012 from
$ logout
Connection to closed.

Shutdown environment

$ vagrant halt

Notes: This command shuts down the running machine Vagrant is managing.

Vagrant will first attempt to gracefully shut down the machine by running the guest OS shutdown mechanism. If this fails, or if the --force flag is specified, Vagrant will effectively just shut off power to the machine.

Accounts — Generate SSH Key

eval `ssh-agent -s`
ssh-keygen -t rsa -C "Firehose Vagrant" -N '' -f ~/.ssh/id_rsa
ssh-add ~/.ssh/id_rsa

Configure Heroku and add SSH

wget -qO- | sh 
heroku login
heroku keys:add

Notes: If you don’t already use SSH and if you want to use SSH Git transport on Heroku, you’ll need to create a public/private key pair to deploy code. This keypair is used for the strong cryptography and that uniquely identifies you as a developer when pushing code changes.

Configure GitHub with SSH key

curl  > ~/.firehose-github.rb && ruby ~/.firehose-github.rb
git config --global "" 
git config --global "Your Name"

Notes: Global level configuration is user-specific, meaning it is applied to an operating system user. Global configuration values are stored in a file that is located in a user’s home directory. ~ /.gitconfig on unix systems and C:\Users\<username>\.gitconfig on windows

Test — Run rails server

cd /vagrant/src/firehose-test-app
$ rails server -b -p 3000

Notes: means that Rails is listening on all interfaces, not just the loopback interface.

— — —

Create an app that uses postgres


$ cd /vagrant/src 

New app that uses postgres

$ rails new splurty --database=postgresql

Notes: Rails expects the name of the database user to match the name of the application, but you can easily change that if need be.

We will now configure which database Rails will talk to. This is done using the database.yml file, located at:


Note: RAILS_ROOT is the Rails root directory. In the above example, it would be at /myapp (relative to your current location).

— — —



$ cd /vagrant/src/splurty

Create database

$ rake db:create 

Notes: When you create your Rails application for the first time, it will not have a database yet. In order for it to start, you will need to make sure the database is up and running.


Created database 'splurty_development'
Created database 'splurty_test'

Access rails console to access database

$ rails console

Notes: The console command lets you interact with your Rails application from the command line.rails console uses IRB (Interactive Ruby).

Database command example

> Quote.create(saying: 'Live life to the fullest', author: 'none')

Exit rails console


— — —

Github workflow

If first-time, initialize.

$ git init

1. Add all to staging area

$ git add --all

2. Commit files and add comment

$ git commit -am "initial commmit"

3. Push files to master

$ git push origin master

push web app to heroku

$ git push heroku master