Here goes another newbie post. I’ve been told over and over again not to dig into Rails 4 yet since there’s not a lot of info out there. But, if I’m learning Rails for the first time, doesn’t it make sense to hash out the differences and not develop habits that are going to be depreciated? So now, I’ve set up my environment so I can have the best of both worlds!

In my newness, I’ve unfortunately allowed a slew of gems in my default gemset which makes things messy when you want to work with various versions of Ruby and or Rails depending on your app. My solution going forward is to create .rvmc files per app (or groups of apps), that will contain custom gemsets so I’m not polluting my default environment. This is best done with a clean (or minimally polluted default gemset), but works fine if you’re like me and already have Rails 3.2.X set as your default.

If you already have RVM installed, go ahead and get the latest version. In terminal run

$ rvm get stable –-autolibs=enable

The --autolibs flag tells rvm to automatically install necessary dependancies on you system as well (important for those of us still with student status)!

From there, you can check for any Ruby updates you want by running

$ rvm list known

Since Rails 5, (gasp, I’m still trying to learn 3.2 and 4) will require 2.0, I figured I might as well get going with that!

To install run

$ rvm install 2.0.0

Of course you can explicitly use any version returned from the known list also.

Now for the fun stuff (many thanks to Kevin Lawver from Rails Machine for helping me with this part)!
In terminal, cd into whichever directory you keep your rails projects, create a new directory for Rails 4, then cd into that one.

$ cd rails_projects
$ mkdir rails_4
$ cd rails_4

From there, you’ll create a directory specific gemset. I’ve explicitly stated I want to use Ruby 2.0.0, but of course you can choose whichever version you like.

rvm –-rvmrc –-create 2.0.0@rails_4

Cd out of that directory, and then cd back in. It will ask you to accept the new .rvmc file which you will of course say yes to.

$ cd ..
$ cd rails_4

For extra assurance you can run

$ ls –a

to see the hidden .rvmc file.
Then, all that’s left to do is to install Rails 4. Don't panic... it may take a few minutes.

$ gem install Rails

Followed by

$ gem install bundler

You can now run

$ rails new myApp

To generate you Rails 4 app.

Written on July 16, 2013