All Aboard!

September 2, 2014

It's finally time to answer the question we have all been asking ourselves over the past eight weeks -- What is Ruby on Rails?

Ruby on Rails (aka Rails) is a web application development framework written in the Ruby language. Rails combines the Ruby programming language with HTML, CSS, and JavaScript to create a web application that runs on a web server. Technically, Rails is a package library (a RubyGem) that is installed using the operating system command-line interface. It is designed to make programming web applications easier by making assumptions about what every developer needs to get started. It essentially allows you to write less code while accomplishing more. But be forewarned, Rails is opinionated software. It assumes that there is the "best" way to do things.

The set of technologies or software libraries that are used to develop an application or deliver web pages is called a technology "stack." As a beginner, your technology stack will likely include Rails, the WEBrick web server (it comes with Ruby), the SQLite database, and the Linux, Mac OS X, or Windows operating system (whatever is installed on your computer). The Rails stack can also include a variety of software libraries (gems) that add features to a website or make development easier. Sometimes the choice of components in a stack is driven by the requirements of an application. At other times, the stack is a matter of personal preference.

Rails' Major Guiding Principles

Don't Repeat Yourself: DRY is a principle of software development which states that every piece of knowledge must have a single, unambiguous, authoritative representation within a system. By not writing the same information over and over again, code is more maintainable, more extensible, and less buggy.
Convention Over Configuration: Rails has opinions about the best way to do many things in a web application, and defaults to this set of conventions, rather than require that the programmer specify every minutiae through endless configuration files.
Rails is Omakase: Omakase is a Japanese phrase that means "I'll leave it to you." In a famous essay, Heinemeier Hansson declared Rails is Omakase, and said, "A team of chefs picked out the ingredients, designed the APIs, and arranged the order of consumption on your behalf according to their idea of what would make for a tasty full-stack framework. When we, or in some cases I - as the head chef of the omakase experience that is Rails - decide to include a dish, it's usually based on our distilled tastes and preferences. I've worked in this establishment for a decade. I've poured well in the excess of ten thousand hours into Rails. This doesn't make my tastes right for you, but it certainly means that they're well formed." Hungry yet? I am!

Where Does Rails Get Complicated?

When Rails Has No Opinion: As you gain experience with Rails, you may encounter areas where Rails doesn't state an opinion. For example, as of early 2013, there was no "official" approach to queueing background jobs. Much of the lively debate that drives development of new versions of Rails is focused on thrashing out the "opinions" that eventually will be included in the Rails API.
Omakase But Substitutions Are Allowed: Implicit in the notion of "Rails is omakase" is an understanding that substitutions are allowed. Professional developers often substitute an alternative testing framework or use a different syntax for creating page views than the "official" version chosen by Heinemeier Hansson.
Conventions or Magic: For a skilled programmer, "convention over configuration" adds obscurity. For example, without a configuration file, there is no obvious code that reveals that data from a class named "Person" is saved to a datatable named "people."
DRY to Obscurity: To avoid repetitive code, Rails often will offer default behavior that looks like magic because the underlying implementation is hidden in the depths of the Rails code library. A programmer can implement a simple web application with only a few lines of custom code but may wonder where all the behavior comes from. This can be frustrating when, as a beginner, a programmer attempts to customize an application to do more than what is shown in tutorials.

How Does Rails Work?

Web servers deliver HTML, CSS, and JavaScript, either from static files that are stored on the server, or from an "application server" that creates files dynamically using a programming language such as Ruby. A software program written in Ruby and organized using Rails conventions is a "web application." Rails combines the Ruby programming language with HTML, CSS, and JavaScript to create a web application. Rails uses Ruby to dynamically assemble HTML, CSS, and JavaScript files from component files (often adding content from a database).

What Does One See On The Computer When Looking at a Rails Application?

The answer is a set of files that a programmer can edit with a text editor to create a web application. The files are organized with a specific structure:


    			+-app
			| +-assets
			| | +-images
			| | +-javascripts
			| | +-stylesheets
			| +-controllers
			| +-helpers
			| +-mailers
			| +-models
			| +-views
			+-config
			+-db
			+-features
			+-lib
			+-log
			+-public
			+-script
			+-spec
			

To install Rails, use the gem install command provided by RubyGems:


    		$ gem install rails

And for a step-by-step guide to creating a new Rails project, check out rubyonrails.org. Personally, I am really looking forward to using Rails! How about you?

← Previous Post
Next Post →