Ruby on Rails 4.x on Windows
Ruby on Rails is excellent Web application development framework whose popularity has tremendously increased in last few years. Most of the popularity it owes to the fact that it makes some common Web development tasks easier. Being based on MVC (Model-View-Controller) architecture, it gives developer possibility to easily scaffold model, view and controller for basic Web site functionality. In a few simple steps developer is able to create working application skeleton. The latest version 4.x targets either Ruby version 1.9.3+ or 2.x. At the moment of writing this chapter not all gems used by Rails are ready for Ruby 2.2 so for this chapter we will use Ruby 2.1.5. Go ahead download and install this version and add it to uru's list of Rubies.
With properly installed and configured Ruby version installing Ruby on Rails is easy and straightforward task. Use uru to switch to new Ruby or if this is the only Ruby version you have on the system just start Rails installation.
C:\>gem install rails --no-rdoc --no-ri
Fetching: thread_safe-0.3.5.gem (100%)
Successfully installed thread_safe-0.3.5
Fetching: minitest-5.5.1.gem (100%)
Successfully installed minitest-5.5.1
Fetching: tzinfo-1.2.2.gem (100%)
Successfully installed tzinfo-1.2.2
Fetching: i18n-0.7.0.gem (100%)
Successfully installed i18n-0.7.0
Fetching: activesupport-4.2.1.gem (100%)
Successfully installed activesupport-4.2.1
Fetching: rails-deprecated_sanitizer-1.0.3.gem (100%)
Successfully installed rails-deprecated_sanitizer-1.0.3
Fetching: mini_portile-0.6.2.gem (100%)
Successfully installed mini_portile-0.6.2
Fetching: nokogiri-1.6.6.2-x86-mingw32.gem (100%)
Nokogiri is built with the packaged libraries: libxml2-2.9.2, libxslt-1.1.28, zlib-1.2.8, libiconv-1.14.
Successfully installed nokogiri-1.6.6.2-x86-mingw32
Fetching: rails-dom-testing-1.0.6.gem (100%)
Successfully installed rails-dom-testing-1.0.6
Fetching: loofah-2.0.1.gem (100%)
Successfully installed loofah-2.0.1
Fetching: rails-html-sanitizer-1.0.2.gem (100%)
Successfully installed rails-html-sanitizer-1.0.2
Fetching: erubis-2.7.0.gem (100%)
Successfully installed erubis-2.7.0
Fetching: builder-3.2.2.gem (100%)
Successfully installed builder-3.2.2
Fetching: actionview-4.2.1.gem (100%)
Successfully installed actionview-4.2.1
Fetching: rack-1.6.0.gem (100%)
Successfully installed rack-1.6.0
Fetching: rack-test-0.6.3.gem (100%)
Successfully installed rack-test-0.6.3
Fetching: actionpack-4.2.1.gem (100%)
Successfully installed actionpack-4.2.1
Fetching: activemodel-4.2.1.gem (100%)
Successfully installed activemodel-4.2.1
Fetching: arel-6.0.0.gem (100%)
Successfully installed arel-6.0.0
Fetching: activerecord-4.2.1.gem (100%)
Successfully installed activerecord-4.2.1
Fetching: mime-types-2.4.3.gem (100%)
Successfully installed mime-types-2.4.3
Fetching: mail-2.6.3.gem (100%)
Successfully installed mail-2.6.3
Fetching: globalid-0.3.3.gem (100%)
Successfully installed globalid-0.3.3
Fetching: activejob-4.2.1.gem (100%)
Successfully installed activejob-4.2.1
Fetching: actionmailer-4.2.1.gem (100%)
Successfully installed actionmailer-4.2.1
Fetching: thor-0.19.1.gem (100%)
Successfully installed thor-0.19.1
Fetching: railties-4.2.1.gem (100%)
Successfully installed railties-4.2.1
Fetching: bundler-1.9.1.gem (100%)
Successfully installed bundler-1.9.1
Fetching: tilt-1.4.1.gem (100%)
Successfully installed tilt-1.4.1
Fetching: multi_json-1.11.0.gem (100%)
Successfully installed multi_json-1.11.0
Fetching: hike-1.2.3.gem (100%)
Successfully installed hike-1.2.3
Fetching: sprockets-2.12.3.gem (100%)
Successfully installed sprockets-2.12.3
Fetching: sprockets-rails-3.0.0.beta1.gem (100%)
Successfully installed sprockets-rails-3.0.0.beta1
Fetching: rails-4.2.1.gem (100%)
Successfully installed rails-4.2.1
34 gems installed
As the most of Web application frameworks, Ruby on Rails heavily relies on a database as a back-end data storage. Through its built-in database adapters it directly supports SQlite3, MySQL and PostgreSQL databases. This is not the end of the list because you can easily install adapters for other databases like Oracle or MS SQL. The only difference is these adapters are not shipped with Ruby on Rails. Common to all adapters is the fact that they actually use additional extension libraries to connect to target database engine. At the first sight it sounds complicated but in the reality it is quite simple to switch the database Rails uses.
Extension libraries for accessing databases were one source of problems on Windows in the past. Natural approach in all Open Source projects is to primarily support and rely on other Open Source projects. Ruby on Rails in no exception. In early RoR days programmers were mostly turned to Linux, leaving Windows behind. At the same time small number of Windows developers, ready to dedicate their spare time to Open Source projects, could not create big enough momentum which would lead to larger number of extension libraries for various databases that work well on Windows. Additional obstacle was the fact that Ruby was built with Visual Studio, commercial project not available to everyone willing to help in this field. Despite this, Windows support was improving over time. Quantum jump has happened with a move to MinGW development environment, just as it did with Ruby.
Not only more developers were able to contribute, but with some additional tools like rake-compiler it became much easier to create binary gems for specific platform, Windows at the first place. This naturally lead to better support and easier upgrade of extensions, since release cycle was shortened. Even more, each developer is now able to build lot of extension libraries by itself, just as we already did with slite3 and mysql2 gems.