Ruby on Rails in Windows Azure - Part 1 - Setting up Ruby on Rails in Windows 7 Machine with test Rails Application

Lets start with main component installation as below:

1. Ruby 1.9.2

2. Rails 3.0.7

Ruby Installation:

https://rubyforge.org/frs/?group_id=167

I have installed it at
C:\Applicaitons\Ruby\Ruby192

 

Gems (Ruby Package Manager) Installation

https://rubyforge.org/frs/?group_id=126

 

Unzip the above zip folder in
C:\Applicaitons\Ruby\ folder.

To start GEM installation use
command ruby
<Path_to>\setup.rb
as below:

 C:\Applications\Ruby>dir

Volume in drive C has no label.

Volume Serial Number is 8464-7B7C



Directory of C:\Applications\Ruby



04/25/2011  01:30 PM    <DIR>          .

04/25/2011  01:30 PM    <DIR>          ..

03/28/2011  04:23 PM            14,996 HelloWorld.docx

03/23/2011  05:04 PM               122 help.txt

03/23/2011  04:45 PM         4,823,453 ruby-1.8.7-p174.tar.gz

03/23/2011  04:48 PM    <DIR>          Ruby192

04/05/2011  02:17 PM    <DIR>          rubygems-1.7.2

03/23/2011  04:45 PM        12,502,696 rubyinstaller-1.9.2-p180.exe

               4 File(s)     17,341,267 bytes

               4 Dir(s)  36,662,747,136 bytes free



C:\Applications\Ruby>ruby rubygems-1.7.2\setup.rb

RubyGems 1.7.2 installed



=== 1.7.2 / 2011-04-05



* 1 Bug Fix:

  * Warn on loading bad spec array values (ntlm-http gem has nil in its cert

    chain)





------------------------------------------------------------------------------



RubyGems installed the following executables:

        C:/Applications/Ruby/Ruby192/bin/gem





C:\Applications\Ruby>

Now adding C:\Applications\Ruby\Ruby192\bin
into System PATH so I can run GEM.

 C:\Applications\Ruby>gem

RubyGems is a sophisticated package manager for Ruby.  This is a

basic help message containing pointers to more information.



  Usage:

    gem -h/--help

    gem -v/--version

    gem command [arguments...] [options...]



  Examples:

    gem install rake

    gem list --local

    gem build package.gemspec

    gem help install



  Further help:

    gem help commands            list all 'gem' commands

    gem help examples            show some examples of usage

    gem help platforms           show information about platforms

    gem help <COMMAND>           show help on COMMAND

                                   (e.g. 'gem help install')

    gem server                   present a web page at

                                 https://localhost:8808/

                                 with info about installed gems

  Further information:

    https://rubygems.rubyforge.org



C:\Applications\Ruby>gem -v

1.7.2

Now we can install Rails as below:

 

 C:\Applications\Ruby>gem install rails

Fetching: activesupport-3.0.7.gem (100%)

Fetching: builder-2.1.2.gem (100%)

WARNING: builder-2.1.2 has an invalid nil value for @cert_chain

Fetching: i18n-0.5.0.gem (100%)

Fetching: activemodel-3.0.7.gem (100%)

Fetching: rack-1.2.2.gem (100%)

Fetching: rack-test-0.5.7.gem (100%)

Fetching: rack-mount-0.6.14.gem (100%)

Fetching: tzinfo-0.3.26.gem (100%)

Fetching: abstract-1.0.0.gem (100%)

WARNING: abstract-1.0.0 has an invalid nil value for @cert_chain

Fetching: erubis-2.6.6.gem (100%)

Fetching: actionpack-3.0.7.gem (100%)

Fetching: arel-2.0.9.gem (100%)

Fetching: activerecord-3.0.7.gem (100%)

Fetching: activeresource-3.0.7.gem (100%)

Fetching: mime-types-1.16.gem (100%)

Fetching: polyglot-0.3.1.gem (100%)

Fetching: treetop-1.4.9.gem (100%)

Fetching: mail-2.2.17.gem (100%)

Fetching: actionmailer-3.0.7.gem (100%)

Fetching: thor-0.14.6.gem (100%)

Fetching: railties-3.0.7.gem (100%)

Fetching: bundler-1.0.12.gem (100%)

Fetching: rails-3.0.7.gem (100%)

Successfully installed activesupport-3.0.7

Successfully installed builder-2.1.2

Successfully installed i18n-0.5.0

Successfully installed activemodel-3.0.7

Successfully installed rack-1.2.2

Successfully installed rack-test-0.5.7

Successfully installed rack-mount-0.6.14

Successfully installed tzinfo-0.3.26

Successfully installed abstract-1.0.0

Successfully installed erubis-2.6.6

Successfully installed actionpack-3.0.7

Successfully installed arel-2.0.9

Successfully installed activerecord-3.0.7

Successfully installed activeresource-3.0.7

Successfully installed mime-types-1.16

Successfully installed polyglot-0.3.1

Successfully installed treetop-1.4.9

Successfully installed mail-2.2.17

Successfully installed actionmailer-3.0.7

Successfully installed thor-0.14.6

Successfully installed railties-3.0.7

Successfully installed bundler-1.0.12

Successfully installed rails-3.0.7

23 gems installed

Installing ri documentation for activesupport-3.0.7...

Installing ri documentation for builder-2.1.2...

Installing ri documentation for i18n-0.5.0...

Installing ri documentation for activemodel-3.0.7...

Installing ri documentation for rack-1.2.2...

Installing ri documentation for rack-test-0.5.7...

Installing ri documentation for rack-mount-0.6.14...

Installing ri documentation for tzinfo-0.3.26...

Installing ri documentation for abstract-1.0.0...

Installing ri documentation for erubis-2.6.6...

Installing ri documentation for actionpack-3.0.7...

Installing ri documentation for arel-2.0.9...

Installing ri documentation for activerecord-3.0.7...

Installing ri documentation for activeresource-3.0.7...

Installing ri documentation for mime-types-1.16...

Installing ri documentation for polyglot-0.3.1...

Installing ri documentation for treetop-1.4.9...

Installing ri documentation for mail-2.2.17...

Installing ri documentation for actionmailer-3.0.7...

Installing ri documentation for thor-0.14.6...

Installing ri documentation for railties-3.0.7...

Installing ri documentation for bundler-1.0.12...

Installing ri documentation for rails-3.0.7...

Installing RDoc documentation for activesupport-3.0.7...

Installing RDoc documentation for builder-2.1.2...

Installing RDoc documentation for i18n-0.5.0...

Installing RDoc documentation for activemodel-3.0.7...

Installing RDoc documentation for rack-1.2.2...

Installing RDoc documentation for rack-test-0.5.7...

Installing RDoc documentation for rack-mount-0.6.14...

Installing RDoc documentation for tzinfo-0.3.26...

Installing RDoc documentation for abstract-1.0.0...

Installing RDoc documentation for erubis-2.6.6...

Installing RDoc documentation for actionpack-3.0.7...

Installing RDoc documentation for arel-2.0.9...

Installing RDoc documentation for activerecord-3.0.7...

Installing RDoc documentation for activeresource-3.0.7...

Installing RDoc documentation for mime-types-1.16...

Installing RDoc documentation for polyglot-0.3.1...

Installing RDoc documentation for treetop-1.4.9...

Installing RDoc documentation for mail-2.2.17...

Installing RDoc documentation for actionmailer-3.0.7...

Installing RDoc documentation for thor-0.14.6...

Installing RDoc documentation for railties-3.0.7...

Installing RDoc documentation for bundler-1.0.12...

Installing RDoc documentation for rails-3.0.7...



C:\Applications\Ruby>

Now Lets try to run Rails application to verify the installation:

 

 C:\Applications\Ruby>rails

Usage:

  rails new APP_PATH [options]



Options:

  -r, [--ruby=PATH]           # Path to the Ruby binary of your choice

                              # Default: C:/Applications/Ruby/Ruby192/bin/ruby.e

xe

  -d, [--database=DATABASE]   # Preconfigure for selected database (options: mys

ql/oracle/postgresql/sqlite3/frontbase/ibm_db)

                              # Default: sqlite3

  -b, [--builder=BUILDER]     # Path to an application builder (can be a filesys

tem path or URL)

  -m, [--template=TEMPLATE]   # Path to an application template (can be a filesy

stem path or URL)

      [--dev]                 # Setup the application with Gemfile pointing to y

our Rails checkout

      [--edge]                # Setup the application with Gemfile pointing to R

ails repository

      [--skip-gemfile]        # Don't create a Gemfile

  -O, [--skip-active-record]  # Skip Active Record files

  -T, [--skip-test-unit]      # Skip Test::Unit files

  -J, [--skip-prototype]      # Skip Prototype files

  -G, [--skip-git]            # Skip Git ignores and keeps



Runtime options:

  -f, [--force]    # Overwrite files that already exist

  -p, [--pretend]  # Run but do not make any changes

  -q, [--quiet]    # Supress status output

  -s, [--skip]     # Skip files that already exist



Rails options:

  -v, [--version]  # Show Rails version number and quit

  -h, [--help]     # Show this help message and quit



Description:

    The 'rails new' command creates a new Rails application with a default

    directory structure and configuration at the path you specify.



Example:

    rails new ~/Code/Ruby/weblog



    This generates a skeletal Rails installation in ~/Code/Ruby/weblog.

    See the README in the newly created application to get going.

 

Ruby comes with embedded version of SQLite name Sqlite3_ruby so lets install it now:

 

 C:\Applications\Ruby>gem install sqlite3-ruby

Fetching: sqlite3-1.3.3-x86-mingw32.gem (100%)



=============================================================================



  You've installed the binary version of sqlite3.

  It was built using SQLite3 version 3.7.3.

  It's recommended to use the exact same version to avoid potential issues.



  At the time of building this gem, the necessary DLL files where available

  in the following download:



  https://www.sqlite.org/sqlitedll-3_7_3.zip



  You can put the sqlite3.dll available in this package in your Ruby bin

  directory, for example C:\Ruby\bin



=============================================================================



Fetching: sqlite3-ruby-1.3.3.gem (100%)



#######################################################



Hello! The sqlite3-ruby gem has changed it's name to just sqlite3.  Rather than

installing `sqlite3-ruby`, you should install `sqlite3`.  Please update your

dependencies accordingly.



Thanks from the Ruby sqlite3 team!



<3 <3 <3 <3



#######################################################



Successfully installed sqlite3-1.3.3-x86-mingw32

Successfully installed sqlite3-ruby-1.3.3

2 gems installed

Installing ri documentation for sqlite3-1.3.3-x86-mingw32...

Installing ri documentation for sqlite3-ruby-1.3.3...

Installing RDoc documentation for sqlite3-1.3.3-x86-mingw32...

Installing RDoc documentation for sqlite3-ruby-1.3.3...

As suggested in Sqlite3_ruby installation, lets download the sqlite3.dll from the link below:

https://www.sqlite.org/sqlitedll-3_7_3.zip

Unzip the DLL and be sure to
place in Ruby\Bin folder and verify as below:

 

 

 C:\Applications\Ruby>dir Ruby192\bin\SQL*.dll

Volume in drive C has no label.

Volume Serial Number is 8464-7B7C



Directory of C:\Applications\Ruby\Ruby192\bin



10/07/2010  10:37 PM           546,205 sqlite3.dll

               1 File(s)        546,205 bytes

               0 Dir(s)  36,548,767,744 bytes free

 

 

Now we have all the pieces needed to create our first application. Let's create a new Ruby on Rails application
name “RubyonAzure” as below:

 C:\Applications\Ruby>rails new rubyonazure

      create

      create  README

      create  Rakefile

      create  config.ru

      create  .gitignore

      create  Gemfile

      create  app

      create  app/controllers/application_controller.rb

      create  app/helpers/application_helper.rb

      create  app/mailers

      create  app/models

      create  app/views/layouts/application.html.erb

      create  config

      create  config/routes.rb

      create  config/application.rb

      create  config/environment.rb

      create  config/environments

      create  config/environments/development.rb

      create  config/environments/production.rb

      create  config/environments/test.rb

      create  config/initializers

      create  config/initializers/backtrace_silencers.rb

      create  config/initializers/inflections.rb

      create  config/initializers/mime_types.rb

      create  config/initializers/secret_token.rb

      create  config/initializers/session_store.rb

      create  config/locales

      create  config/locales/en.yml

      create  config/boot.rb

      create  config/database.yml

      create  db

      create  db/seeds.rb

      create  doc

      create  doc/README_FOR_APP

      create  lib

      create  lib/tasks

      create  lib/tasks/.gitkeep

      create  log

      create  log/server.log

      create  log/production.log

      create  log/development.log

      create  log/test.log

      create  public

      create  public/404.html

      create  public/422.html

      create  public/500.html

      create  public/favicon.ico

      create  public/index.html

      create  public/robots.txt

      create  public/images

      create  public/images/rails.png

      create  public/stylesheets

      create  public/stylesheets/.gitkeep

      create  public/javascripts

      create  public/javascripts/application.js

      create  public/javascripts/controls.js

      create  public/javascripts/dragdrop.js

      create  public/javascripts/effects.js

      create  public/javascripts/prototype.js

      create  public/javascripts/rails.js

      create  script

      create  script/rails

      create  test

      create  test/fixtures

      create  test/functional

      create  test/integration

      create  test/performance/browsing_test.rb

      create  test/test_helper.rb

      create  test/unit

      create  tmp

      create  tmp/sessions

      create  tmp/sockets

      create  tmp/cache

      create  tmp/pids

      create  vendor/plugins

      create  vendor/plugins/.gitkeep



C:\Applications\Ruby>

 

The above command will create the Ruby application skeleton code for us in a predefined Ruby application pattern. You can check the application
folder as below:

 

You can check the application
folder as below:

 

 C:\Applications\Ruby\rubyonazure>dir

Volume in drive C has no label.

Volume Serial Number is 8464-7B7C



Directory of C:\Applications\Ruby\rubyonazure



04/25/2011  01:58 PM    <DIR>          .

04/25/2011  01:58 PM    <DIR>          ..

04/25/2011  01:51 PM                36 .gitignore

04/25/2011  01:51 PM    <DIR>          app

04/25/2011  01:51 PM    <DIR>          config

04/25/2011  01:51 PM               161 config.ru

04/25/2011  01:51 PM    <DIR>          db

04/25/2011  01:51 PM    <DIR>          doc

04/25/2011  01:51 PM               743 Gemfile

04/25/2011  01:58 PM             1,642 Gemfile.lock

04/25/2011  01:51 PM    <DIR>          lib

04/25/2011  01:51 PM    <DIR>          log

04/25/2011  01:51 PM    <DIR>          public

04/25/2011  01:51 PM               271 Rakefile

04/25/2011  01:51 PM             9,126 README

04/25/2011  01:51 PM    <DIR>          script

04/25/2011  01:51 PM    <DIR>          test

04/25/2011  01:51 PM    <DIR>          tmp

04/25/2011  01:51 PM    <DIR>          vendor

               6 File(s)         11,979 bytes

              13 Dir(s)  36,548,046,848 bytes free



C:\Applications\Ruby\rubyonazure>

 

 

Once satisfied, lets launch the
sample application using “rails server” in the application folder below:

 

 

 

 C:\Applications\Ruby\rubyonazure>rails server

=> Booting WEBrick

=> Rails 3.0.7 application starting in development on https://0.0.0.0:3000

……

 

 

 

 

During the start the following
Security Alert will be displayed so accept it:

 

 

 

Finally you will see the
following log at command prompt to show that application is running in
localhost:3000:

 

 

 C:\Applications\Ruby\rubyonazure>rails server

=> Booting WEBrick

=> Rails 3.0.7 application starting in development on https://0.0.0.0:3000

=> Call with -d to detach

=> Ctrl-C to shutdown server

[2011-04-25 13:58:57] INFO  WEBrick 1.3.1

[2011-04-25 13:58:57] INFO  ruby 1.9.2 (2011-02-18) [i386-mingw32]

[2011-04-25 13:58:57] INFO  WEBrick::HTTPServer#start: pid=9236 port=3000

 

 

 

Now you can open the browser at https://localhost:3000
to test the application as below:

 

 

Now Click at “About your
application’s environment” as below:

 

Part 2: https://blogs.msdn.com/b/avkashchauhan/archive/2011/04/26/ruby-on-rails-in-windows-azure-part-2-creating-windows-azure-sdk-1-4-based-application-to-host-ruby-on-rails-application-in-cloud.aspx