Setting Up Ruby on Rails on Windows

This post describes how to setup Ruby on Rails on Windows to start developing a Rails application for the first time.

I attempted initially to setup Rails with XAMPP or Apache, but they did not seem to work well together.
The following shows how to setup the Rails development environment (on Windows) using Rails' built-in WEBrick web server.

Also, see Developing Ruby on Rails Application for Heroku.

  1. Download RubyInstaller from http://rubyinstaller.org/downloads.
  2. Install Ruby using the installer. You can install Ruby on any directory (the following uses C:\ruby).
  3. cd C:\ruby\bin
    (Go to the Ruby's bin folder)
  4. gem update

    When you get the following error:

    ERROR: Error installing json: The 'json' native gem requires installed build tools. Please update your PATH to include build tools or download the DevKit from 'http://rubyinstaller.org/downloads' and follow the instructions at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
    1. Install DevKit:
      1. Download DevKit from http://rubyinstaller.org/downloads.
      2. Extract to a folder (the following uses C:\ruby-devkit).
      3. cd C:\ruby-devkit
        (Go to the DevKit folder)
      4. ruby dk.rb init
      5. Check if config.yml has the right Ruby installed path.
      6. ruby dk.rb review
        (This is optional)
      7. ruby dk.rb install
    2. Run again.
  5. gem install rails --include-dependencies

    When you get the following error:

    ERROR: While generating documentation for i18n-0.6.0 ... MESSAGE: error generating I18n.html: incompatible encoding regexp match (UTF-8 regexp with IBM437 string) (Encoding::CompatibilityError) ... RDOC args: --op C:/ruby/lib/ruby/gems/1.9.1/doc/i18n-0.6.0/rdoc lib --title i18n-0.6.0 Documentation --quiet
    1. set RDOCOPT="--encoding=UTF-8"
    2. Run again.
  6. cd new-app-path
    (Go to a folder for a new Rails application)
  7. rails new new-app-name
    Creates a new Rails application.

    When you get SSL error, like the following:

    Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
    1. Create gemrc file at the home path, with the following line:
      :ssl_verify_mode: 0
      (See http://stackoverflow.com/questions/10246023/bundle-install-fails-with-ssl-certificate-verification-error)
  8. cd new-app-name
    (Go inside the new Rails application folder)
  9. rails server
    Runs the Rails server locally.
    (Need to run from the application's root folder)
  10. Test to see the new Rails application at http://localhost:3000 (from an internet browser).

Resource: