Installing Ruby on Rails on OS X with rbenv

I decided to do a full install of OS X when Yosemite came out and that included installing Ruby and Ruby on Rails on my machine again. Over the last couple of years, I’ve switched from rvm to rbenv because it is a lighter weight solution. Here are the steps that I take to install Ruby on Rails on OS X today

Continue reading “Installing Ruby on Rails on OS X with rbenv”

Installing Ruby on Rails on Ubuntu

I decided to install Ubuntu 13.10 on my current desktop to compare developing on Ubuntu versus OS X. As I needed to install Rails as well I decided to document the steps for future reference as well.

Continue reading “Installing Ruby on Rails on Ubuntu”

Installing Ruby on Rails on OSx

I got myself a Macbook Air today to primarily be a development machine. For those of you who are looking for a shortcut, check out RailsInstaller that does a quick job as well. Personally, I just wanted to give a shot of installing Rails from scratch because it’s a good way of really understanding your system and the appropriate pre-requisites to run Rails. Also, it allows you to specify what version of Rails and ruby you want installed on your system.

I assume that you already have Homebrew installed on your system.

  1. Install RVM
    run curl -L https://get.rvm.io | bash
  2. Re-load your environment
    source ~/.rvm/scripts/rvm
  3. Setup additional pre-requisites
    brew install libyaml
    brew install openssl
  4. Install ruby 2.0.0 and set it as the default version
    rvm install 2.0.0 –with-openssl-dir=$HOME/.rvm/usr
    rvm –default use ruby-2.0.0-p247
  5. Install Rails and Bundler
    gem install rails –version=3.2.14
    gem install bundler
  6. Install SQLite which is good quick database for development purposes
    brew install sqlite3

Rails Rake Database Operations

The operations that I most commonly use are db:create, db:migrate and db:reset. I was working with someone and found db:schema:load. I was pleasantly surprised when I came across this list of operations on Stack Overflow.

  • db:create creates the database for the current env
  • db:create:all creates the databases for all envs
  • db:drop drops the database for the current env
  • db:drop:all drops the databases for all envs
  • db:migrate runs migrations for the current env that have not run yet
  • db:migrate:up runs one specific migration
  • db:migrate:down rolls back one specific migration
  • db:migrate:status shows current migration status
  • db:migrate:rollback rolls back the last migration
  • db:forward advances the current schema version to the next one
  • db:seed (only) runs the db/seed.rb file
  • db:schema:load loads the schema into the current env’s database
  • db:schema:dump dumps the current env’s schema (and seems to create the db as well)
  • db:setup runs db:schema:load, db:seed
  • db:reset runs db:drop db:setup
  • db:migrate:redo runs (db:migrate:down db:migrate:up) or (db:migrate:rollback db:migrate:migrate) depending on the specified migration
  • db:migrate:reset runs db:drop db:create db:migrate

Installing Ruby on Rails 3.0 on Ubuntu

I decided to spin up a Rails environment on Ubuntu 12.04 desktop as I wanted to isolate a testing problem. Looks like it was an environment issue on my desktop :D.

  1. Update your package repository
    type sudo apt-get update
  2. Install git and curl
    type sudo apt-get install git curl
  3. Install RVM and Dependencies
    type curl -L get.rvm.io | bash -s stable to download the latest rvm scripts
    type source ~/.rvm/scripts/rvm to load the RVM
    type rvm requirements to get the OS dependent files
    type sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config from the rvm requirements output
  4. Install Ruby 1.9.3
    type rvm install 1.9.3
    type rvm use 1.9.3 — default to set the default version of ruby for the machine
  5. Install Node.js – a Javascript engine
    type sudo apt-add-repository ppa:chris-lea/node.js – add a private repository
    type sudo apt-get update – update repository
    type sudo apt-get install nodejs – install nodejs as the Javascript Engine
  6. Install Rails
    type gem install rails