← Some Random Stuff And Perhaps A Cookie

Kirby Week 2010: Welcome to Rails 3

On the first day of Kirby Week, Four Island gave to me: A tutorial on how to get Rails 3.

Oh my god, it's Kirby Week. That. Was. Fast. I just remembered yesterday (which was the first day of Kirby Week, but I didn't have to post on Sunday anyway) that I usually post once a weekday for Kirby Week (except Friday, which I have traditionally failed at life on :P ). Right. Anyway, since I have been doing a lot of work with Ruby on Rails recently with Four Island 3, I think I should focus this year's Kirby Week on Rails! :D

Now, I have been using Rails 3 to develop Four Island 3 (OH MY GOD THE THREES! RUN AWAY!!!!!) and it's quite nice. It doesn't seem beta-ish at all, and do you know why? Because it isn't beta-ish at all! :P Today, I'm going to show you how to install Rails 3 (as well as some other stuff) onto your computer because Rails 3 is pretty awesome yo dawg business. O_O

Now, as you may know, Rails 3 requires Ruby 1.9. Ruby 1.9 is pretty awesome, but it breaks a lot of old Ruby programs, so we're going to install it alongside your system Ruby installation by using something called "rvm", or the Ruby Version Manager. Note that this will only work on UNIX-based OSes, that means Linux and OS X (no Windows! :P ). First, ensure that you have "git" installed. Second, open a terminal and run this command:

bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

It seems pretty mysterious, but all it does is download rvm. You're not quite done yet--you have to inject rvm into your bash session. To do this, follow the instructions that the above command showed you, or just add this line to your ~/.bash_profile file:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.

Next, open a new bash session or just source the profile (source ~/.bash_profile) to load rvm into your session. Finally, just ensure that everything worked by running the following command:

type rvm | head -1

If it replies with rvm is a function, then congratulations! You've successfully installed rvm, and not much else yet! :P Just to keep things safe, run rvm notes to see if there's anything special you have to do for your particular operating system (for instance, I believe you need to have Xcode installed for OS X).

Great! Now, let's install Ruby 1.9.2. It's fairly simple--just run the following commands:

rvm install 1.9.2
rvm --default use 1.9.2
rvm default

The first line is the one that will take a while, but it's a fairly simple process overall--it just installs Ruby 1.9.2, sets it as the default ruby and then chooses it to be the interpreter for the current session.

Finally, let's install Rails 3. Run the following command:

gem install rails

Note that you should never use sudo when installing gems when you are using rvm. Anyway, yes, it really was that easy. Now that you have Rails 3 installed, you should explore the great wondernesses of its wonderness! :P You should read that page. Yes. Anyway, I'm going to be writing about some cool tips and tricks of this you can do with Rails this week and it's going to be great. :D And, now that you have Rails 3 like I do, you can be sure they'll work! :P

Oh, and if you ever want to switch back to your system's default Ruby, run this command:

rvm use system
Hatkirby on December 13th, 2010 at 12:30:13pm
👍 0 👎

Comments

Replying to comment by :
Feel free to post a comment! You may use Markdown.