Apr 28, 2013

Updating Ruby, Gem, and Rails versions ...

Hanging out on a beautiful San Francisco Sunday at Hack Reactor.  Been burning hours trying to implement _.last method from underscore library from scratch.  Hours because I suck at JavaScript (definitely learning more Chrome dev tools, though).  Anyway, after banging my head on trying to understand how to implement the _.last on functions, which involves prototype.call chain (I think), I decided to take a little break to upgrade my Ruby on Rails versions which have fallen out of date.

I want to share the links I've used and they worked straight up from command line for me.  With Ruby on Rails (RoR), you'll want to update three areas: Ruby itself, Rails framework, and Gems.
Updating gems

My gem version was 1.8.24, pretty out of date.  Go to http://rubygems.org/.

~$ gem update --system

Ruby (rvm first)
I was running 1.9.3 on Ubuntu.  As it was, I am a Ruby Rookie, so I wasn't using rvm (primarily because when I first started and had installed, I was on Windows and there is no rvm for Windows.

However, on Ubuntu, the following blog post worked well for me.

Since you likely have curl and all that jazz, skip to the bash script and remember to change your .bashrc home name ... as Andrei points out in his blog.

bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)  

You may need to reload:
~$ rvm reload

This does not upgrade me to Ruby 2.0.0.  It does however install the rvm, which will make future version installations easier.  For example, type:

~$ rvm use 2.0.0

and you'll be told "ruby-2.0.0-p0 is not installed."  And then told to do:

~$ rvm install ruby-2.0.0-p0

You may have to update some packages and such, but that should basically get you there.

Rails is a gem, so you want to associate the correct rails version to your gemset.  To select between your installed gemsets, you can use:

~$ rvm gemset list

So, let's say you want to install the latest rails to your gemset called 2.0.3, you could do something like:

~$ rvm gemset create rails4

will create a set you can remember is associated with latest rails.  For more on rvm basics, you can go to the source.

Once you have the up-to-date gems, then Rails is simple:

~$ gem install rails

see bottom lines - run rails --version, ruby --version, gem --version

No comments: