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”

Re-installing ruby after upgrading to OS X Yosemite

I recently upgraded to OS X Yosemite and ran brew install. As a result, my rails setup failed. In the past, re-install ruby worked. However, in this case, when I re-installed it I ran into this issue

BUILD FAILED (OS X 10.10 using ruby-build 20141016)

Inspect or clean up the working tree at /var/folders/93/p8zdbgn14j99_l5x7js97zkm0000gn/T/ruby-build.20141020234934.40511
Results logged to /var/folders/93/p8zdbgn14j99_l5x7js97zkm0000gn/T/ruby-build.20141020234934.40511.log

Last 10 log lines:
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for cd using physical directory... cd -P
checking whether CFLAGS is valid... no
configure: error: something wrong with CFLAGS=" -O3 -Wno-error=shorten-64-to-32 "
make: *** No targets specified and no makefile found. Stop.

To fix the issue, I had to reinstall ruby with the following flags:

RUBY_CONFIGURE_OPTS="--without-gcc --disable-install-rdoc" rbenv install 2.1.3


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