Go from .NET to Ruby in One day. For (and by) the complete Linux n00b

There are 1001 guides out there for installing bits and pieces of Ruby, Linux or Rails. This is intended as an absolute beginners guide, specifically for Windows users who don't know jack about Linux, Ruby OR Rails. I'm a complete n00b at this. I spent a day or two trying to get this setup, finally worked it out and have gone back and done it all again whilst writing this guide on how I did it. I've tried to find the easiest way with the least complications. Advanced users will laugh at me, but they can go #&^$ themselves. If this whole setup wasn't so difficult to use, I wouldn't have needed to spend so long working out half of this stuff in the first place.  I hope it helps other .NET Ruby hopefuls, but please keep in mind, I am FAR from an expert, so comments/improvements/suggestions are more than welcome! I was issued something of a challenge last week: To write our next web app in Ruby. Not such a big deal right? I mean, it's just another language? Can't be that hard? I read this quickstart guide, and whilst Ruby is rather odd little language, it didn't appear to be anything that I couldn't handle. So, I decided to give it a go.. The first thing I'd suggest as a .NET developer of nearly 10 years, is that if you're seriously considering giving Ruby on Rails a go, I strongly suggest playing around with .NET MVC first. As a big fan of MVC, getting into Rails was a lot easier, as many of the concepts found in MVC were...well...stolen fromRails. If you're familiar with Models, Views, Controllers, lambda expressions, partials and all that stuff, Rails will be a breeze. Ruby is still an ugly SOB in my opinion...but at least Rails will feel familiar to you.

Step 1. Installing Linux.

You could use Cygwin, or even Windows, but I'd really suggest not. I tried this, and it's just a pain in the ass. Besides, you won't be using either in our production environment, so you best get used to Linux sooner rather than later! I chose Ubuntu, just because that's what came up in Google. If that statement doesn't make it clear, I'm a complete Linux beginner. I used Linux about 10 years ago, and haven't touched it since. So if lack of knowledge of Linux is what's been stopping you, have no fear. If I can manage it, anyone can. You have a couple of options to get up and running with Linux. Setup a new Linux box, or run a Virtual Machine. I didn't have a spare box lying around, so I chose the latter. So, first thing you'll need to do is go off and download Oracle VM VirtualBox and Ubuntu. Then mount the Ubuntu ISO as a virtual CD drive in Windows (there are plenty of apps to do this, google it). Install VirtualBox and create a New Machine, Call it Linux, choose Linux/Ubuntu as your OS Type. You can pretty safely click next repeatedly during the rest of the install. Once it has installed the VM, go to settings > storage. Click the little empty CD controller and from the CD/DVD device on the right, choose the drive which has your Linux ISO. Click ok and start up the VM. If you've done everything right to this point, Ubuntu should start installing. If it crashes because it can't find your ISO, go back and check your settings. Assuming you have a fairly standard machine, it should all install easily enough. Skip the language packs if you don't need them, they take forever to download and install. Once it has installed, you'll need to "power off" the VM, and remove the ISO so that Linux can boot. When you first get into Linux, it'll want to install a heap of updates...just let it. Ok, so If you're a Linux n00b like me, you wont even know where to start. In fact, you're probably wondering why the damned VM window is so small. To fix this, go to the Devices menu in VirtualBox, click the Install Guest Additions. This will mount another ISO in Linux. Go to Applications>Accessories>Terminal. Welcome to Linux's DOS prompt :P
cd /media
cd VBOXADDITIONS_3.2.0_61806/
(bit of a tip for the REAL n00bs...rather than typing the directory, just hit TAB and it will autocomplete)
sudo sh ./VBoxLinuxAdditions-x86.run
This will go off and install a heap of stuff to make Linux run nicer with your host environment....including allow you to have nicer screen resolutions. Once it is done, do a reboot. Couple of quick tips. Right Ctrl is your host key. Ctrl+F will give you fullscreen. That's it. Step 1 complete! The best part is that you haven't completely committed to using Linux, it's not too late to back out. You're only ever a delete key away from being back in the safe hands of Uncle Bill and his crazy Cousin Steve.

Step 2. Installing Ruby.

Unfortunately, that was the easy part. The next part caused me a lot of grief. I eventually worked it out, but only after a lot of Googling, and a lot of swearing and it turns out I didn't actually need to do most of it. Hopefully I can save you from the same fate. The first thing you need to know is, whenever Googling, resist the temptation to Cut and Paste helpful command line tips and tricks. These often include references to a specific version of a package, and can screw everything up real quick. If you need to install ANYTHING, make double sure that you've got the right version. The problem here is that so many versions of Ruby, Gems and Rails have come and gone, and the installation methods, requirements and problems are all different. This can be a major headache for Linux beginners! Even going through this the second time, I'm still running into issues! So, crack open the terminal again. If you haven't already guessed you'll spend a lot of time here! First thing to note is a command called "sudo". Sudo is the Linux verison of "run as administrator". Most of the commands you run for installation will be prefixed with this. It will prompt you with your admin password and then carry on. Second thing to note is that for the most part, you won't need to download anything from any third party website when doing installs.  Linux has a rather nifty package installer that gets and installs everything for you! If you're keen you can download source packages and compile them yourself, but we won't need to do any of that. So theoretically, Ubuntu should have most of what you need already, but we do need to go get a few bits and pieces. Make sure that the updater has finished before trying this, as it won't work if it is still running. The first thing you need is ruby.
sudo apt-get install ruby-full build-essential
Run this to make sure it installed ok.
ruby -v
This will print the version you just downloaded (hopefully!) This will go off and get the latest version of ruby and install it and a heap of other libraries for you.  Done! You've run your first Linux command and installed ruby! To install gems :
sudo apt-get install rubygems
Run this to make sure it installed ok
gem -v
While you're here, install the ruby-debug gem
gem install ruby-debug
Done and done.

Step 3. Installing Rails

Ok, so now we have ruby, and ruby gems. Now we need rails.
sudo apt-get install rails
Yeah...that's it. Now that all looks pretty simple, and you could've done most of it from the one line. But there are PLENTY of guides out there that will show you how wget your source packages, untar them, compile them, run them blah blah blah. Linux zealots want to know why people still use Windows over Linux? Have a read of your guides! You have to have a PhD in astrophysics just to learn how to run a web app!

Step 4.  Install your IDE

Given that you're a .NET developer, you're going to need an IDE. None of this command line editing BS. We'll be using Aptana Studio. Go here: http://www.aptana.org/studio/download Download the archive. You're most likely using Firefox, so you should be able to find the zip in the downloads folder. Extract the archive to your home directory. You can then run aptana directly from there. You can also create a shortcut in your Applications menu. In Ubuntu, go to Preferences > Main Menu > Programming. Click the New Item button. Fill in the details, navigate to Aptana executable and select it, and also click the icon to change it to the Aptana one. Click Ok, close. And check it out in your Applications menu! Great, that was easy! Well...not so fast! This is Linux! You can't install something so easily! You need to do some more command line hacking. Ubuntu doesn't come with Sun Java, which appears to be a prerequisite for Aptana. So now we need to install that. First we need to add the java repo:
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
Then get the updated list of files
sudo apt-get update
Then install Java
sudo apt-get install sun-java6-jre
You can now run Aptana. Once you open Aptana, you'll also want to click on the Plugins button and install RadRails. It's pretty self explantory. That's about all you need to get up and running. If at this point, you're wondering "why the hell am I doing this???", I don't blame you!  We're nearly done...hang in there! At this point you should be able to run a pretty basic website. So this a good time to....

Step 5.  Watch a video

As you won't have installed it, you'll need to install curl before you get too far in the video, and mongrel (a webserver) too. Just run:
sudo apt-get install curl
sudo apt-get install mongrel
If you ever find yourself missing something, that's usually a good way to try to install it. This 15 minute video will take you about 2 hours to get through. With a bit of luck, everything you've done till now will see you through the video. Use Aptana as your text editor for the examples. You'll be pausing every ten seconds, but stick with it. By the end of it you'll understand why so many developers love RoR....even if you still think Ruby is a pile of poo (like me), you'll see how quick it is to get something up and running in Rails. Before watching the video, make sure you create yourself a code directory.
cd ~
mkdir code
cd code
And now enjoy the video! http://media.rubyonrails.org/video/rails_blog_2.mov

Step 6. What next?

The good news is, that if you got through the video and everything worked, then you have everything you need to create your first web app. One good thing about Ruby is that there is a plethora of resources out there to get you moving from here. The one major pitfall is that there are HEAPS of tutorials that are hopelessly out of date, and can not only lead you astray but cause you some serious headaches if you mess up your installation! There is a lot still to learn about RoR, especially for me, but I hope this is a good starting point. My goal was to write something that got ME up and running. I figure there are plenty of Windows developers out there (like me) that wouldn't have the foggiest idea where to start, so if that is you, I hope this has helped! Cheers, Alan