Thursday, March 28, 2013

Getting Started with Ruby on Rails for Windows


What is Ruby on Rails?

In short, a dynamic (non-compiled) programming language.  If you have programmed before, this is an easy to learn, easy to code programming language.  Check out this link for more info: http://rubyonrails.org/ 

What you'll need?

Here's what you'll need to get started:
  • Windows PC (preferably Windows 7 or Server 2008 and above)


Install Steps:

Before you get started, you really should be an admin on your Windows computer. I'll assume you are for future steps.

Preparation

  1. Sign up for a free GitHub Account (Free for public work) here: https://github.com/.
    1. While you're at it, download and install the github application. This can make it easier to configure and use github on your computer.
    2. As a side note, I like using the Git Shell (powershell) over the command prompt for git work.

Installations

  1. Download and install the RailsInstaller package from http://railsinstaller.org.
    This package is designed to get you up and running on the current ruby and rails versions (as packaged) quickly and painlessly.
    You could stop here; but there are a few other items that I install in order to make my environment more friendly moving forward. Check out the documentation on railsinstaller.org to see everything it installs. In later posts, I'll help you upgrade and update ruby and rails when an update comes out.
    Install this on your computer.  I recommend C:\Railsinstaller to keep things simple.
  2. Download and install PIK from https://github.com/vertiginous/pik. This is an easy to use ruby version manager; which will let you run multiple versions of Ruby on your Windows machine at the same time without wrecking the install done from railsinstaller. 
    1. After railsinstaller is installed, the version of ruby that got installed with it will be your 'base' version.  PIK is used to download and run updated versions of ruby side-by-side.  Each ruby folder you create/download will be independent of the primary version.
    2. Install pik using the gem install pik command, then extract/install it to c:\bin.  We’ll be adding this location to the path variable in the next section.
    3. After PIK is installed, configure your downloads and installs folder.  I recommend using c:\downloads and c:\installs to keep things easy. The ‘downloads’ folder will be used to cache your ruby downloads and the ‘installs’ folder will be the actual final installation path of each version of ruby (subfolders within).
      1. Do this in windows with these commands in an administrative command prompt:
      2. >pik config downloads=c:\downloads
      3. >pik config installs=c:\installs
    4. This is all we’re going to do with PIK at the moment since we’ve just installed what we believe to be the latest version of everything.3.    
  3. Download and install Sublime Text 2 from http://www.sublimetext.com/.  This is a great code editor for Windows/Mac that will highlight and tab your code as needed while you edit it.
    After you install it, copy sublime_text.exe and rename the copy subl.exe or sublime.exe as alternative methods launch it from the command prompt.  Then add the sublime text path to your Path variable (See later step).  You'll thank me later.
  4. Sign up for a Heroku Account (Free for development work) here: http://www.heroku.com/.
    1. While you're there, download and install the heroku toolkit.
  5. Download and install Console2 from http://sourceforge.net/projects/console/
    1. Extract all files to the C:\bin\ folder.  This will be included in path later. See my link to other references below for even more configuration options.
  6. Download and install ANSICON from http://github.com/adoxa/ansicon.
    This application allows for color coding in the command prompt; which is helpful for some ruby applications.
    1. Extract it to c:\bin\ in its own folder.  We’ll be adding that to path later anyway.
    2. Run ansicon –i to configure ansicon to always start with the command prompt for just you or –I for all users on the system.
    3. See my link to other references below for even more configuration.

Tidy Things Up


With everything installed, it’s time to update your Path environment variable so that when you type commands in the command prompt they will reference the correct locations in the order we need.
I use this for my path.  Basically, it prioritizes the main installed version of the major utilities over the rails installer version; but will fall back on it if you uninstall it: c:\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Sublime Text 2\;C:\Program Files (x86)\Notepad++;C:\Program Files (x86)\Heroku\bin;C:\Program Files (x86)\git\cmd;C:\RailsInstaller\Git\cmd;C:\bin\ansi161;C:\bin\ansi161;C:\bin\ansi161\x64;C:\installs\Ruby-193-p392\bin;C:\RailsInstaller\Ruby1.9.3\bin

Time to Play

Now, time to get started playing with Ruby! :-)
I recommend a few websites for beginners:

Other references

Other References that I really like:


Tune in later for my how-to on using PIK to install an updated version of Ruby, then updating ruby and gems as needed to run your application in the new version.

Thanks for coming by,
Jess

No comments: