What Is Ruby on Rails?

Image credits: RubyonRails.org

A Web Development Framework for Purists

Back in 1995, Yukihiro Matsumoto released Ruby 0.95 as a pure, object-oriented (OO), general-purpose programming language:

As a language maniac and OO fan for 15 years, I really wanted a genuine object-oriented, easy-to-use scripting language. I looked for but couldn't find one. So I decided to make it. — Y. Matsumoto

Then in 2004, David Heinemeier Hansson released the first version of Ruby on Rails as a web application framework which he used to launch his team management application Basecamp. He open sourced Ruby on Rails in 2005, and Apple released it with OS X Leopard in 2007.

For this tutorial, I'll refer to Ruby on Rails as Rails for short; some people also use RoR.

Rails is used by a wide variety of popular web applications you may know, such as GitHub, Shopify, Airbnb, Twitch, SoundCloud, Hulu, Zendesk, Square, and Highrise. However, it's been criticized for scalability limitations, most notably with Twitter, which gradually had to move many of its services to other platforms. That said, Twitter has high transaction rates and scalability challenges.

What is Ruby on Rails Sample Rails Apps with Juggler for fun

In this tutorial, I'll answer the question "What is Ruby on Rails?" and introduce you to the basics of the programming framework to help you experiment with it.

Before we get started, please remember, I participate in the discussions below. If you have a question or topic suggestion, please post a comment below or contact me on Twitter @reifman

What Is Ruby on Rails?

Ruby on Rails is a popular, open-source, object-oriented web development framework used by many programmers and application providers. It's also based on a model view controller (MVC) approach.

Models map to the databases and functionality to an object in the application, such as users. Rails provides a standard convention for naming and file directory structures, which simplifies programming but also provides for automated solutions to building functionality, called scaffolding. It also ensures a common environment for developers to work together and benefit from each other's efforts.

Optimizing for programmer happiness with Convention over Configuration is how we roll.

The Controller manages requests primarily between the user and the server, gathering data from models and returning it to the user through View files.

Views are essentially programmatic HTML files that lay out the page with the dynamic data.

Rails conventions guide developers to rely on RESTful routing. Controller actions generally e.g. new, create, edit, update, destroy, show, index, etc. These are what allow for users and the system to interact with various features

Collectively, the MVC features of Rails are called the Action Pack, i.e. ActionController, ActionView and ActiveRecord, the latter for interacting with the database.

What is Ruby on Rails The Action Pack View Controller Record

Rails' founder Hansson provides a principled theology behind the framework called The Ruby on Rails Doctrine.

What is Ruby on Rails The Rails Doctrine

The Ruby on Rails Doctrine

The Rails doctrine consists of eight tenets:

  1. Optimize for programmer happiness: whenever possible, Ruby attempts to meet the desires of the programmer.
  2. Convention over Configuration: choosing standard, platform-wide default choices makes it faster and easier for programmers to get started on new projects.
  3. The menu is omakase: the team behind Ruby on Rails has selected the best tools and approaches, and everyone will be happier using them.
  4. No one paradigm: in the end Rails embraces flexible solutions for various occasions.
  5. Exalt beautiful code: a primary focus on aesthetics and simplicity.
  6. Value integrated systems: an orientation towards complete awareness and cohesion of all the tools needed to build applications and solutions.
  7. Progress over stability: a willingness to take risks to move the platform forward.
  8. Push up a big tent: welcoming a big community of participants and their voices to set the vision.
The chief accomplishment of Rails was to unite and cultivate a strong tribe around a wide set of heretical thoughts about the nature of programming and programmers. — David Heinemeier Hansson

Here are the primary Rails contributors currently (founder David Hansson is in the upper left):

What is Ruby on Rails The Core Team

And they do have a warm, welcoming community:

Perhaps you're interested in diving in further, so here's how to get started.

Getting Started With Ruby on Rails

Rails has a collection of outstanding documentation. Here's a peek at the Getting Started Guide:

What is Ruby on Rails Getting Started

The guide steps you through a general introduction, basic installation and some beginner Rails programming.

Installing Ruby on Rails

Mac users will find Ruby pre-installed. Windows users can check out RailsInstaller. For a full Rails installation on OS X, the guide recommends Tokaido. Alternatively, Daniel Kehoe suggests avoiding one-click installers and provides detailed instructions for Mac OS X El Capitan install.

Experienced Rails developers also report that it makes web application development more fun. — Rails Guide

However, it had been a while since I'd run Rails, and reinstalling it on my late model Mac on El Capitan was time-consuming.

Verify the Installation of Ruby

On OS X, Ruby will be pre-installed:

Install the Rails Framework

My Rails installation took about 10 to 15 minutes (be patient):

But, it worked:

Create Your Application and Framework Instance

Then I created a new application called blog:

You can browse the Rails web application framework directory structure within your application:

Here's a view from the Getting Started guide showing how Rails relies on convention over configuration:

What is Ruby on Rails Directory Structure Convention

Launch Your Server

Finally, you can launch your server with a command line:

Visit Your Application

In your browser, go to http://localhost:3000, and you should see your default home page for a generic Rails application:

What is Ruby on Rails Welcome Page of New Application

I have to say, I wish all this was a bit cleaner. That said, there are some wonderful community resources to help you grow.

Going Deeper

Here's an example of a free GoRails screencast covering the basic framework application architecture shown in the directory above:

And the Rails Guide itself walks you through a number of beginning steps:

What is Ruby on Rails The Getting Started Guide Table of Contents

Overall, there are a wide variety of written and screencast tutorials out there to guide you.

In Closing

If you're intrigued by the quality of Ruby on Rails and its community, I hope you've found this introduction a helpful starting point. Maybe you've even tried the install above.

More recently, I'm intrigued by Apple's open sourcing of Swift, an exciting entrant into the object oriented programming language space, akin to Ruby with similar long-term potential to Rails.

While I've worked with Rails in the past, I've also had struggles with it, especially with hosting and expanding functionality — I've also found hosting it more expensive. I continue to be most comfortable with Yii, which you can read about in our Envato Tuts+ Yii2 Programming Series. And with PHP 7 emerging, the future looks faster and brighter for PHP-based programming frameworks.

If you have questions, please post them below. Or, you can contact me on Twitter @reifman. Please check out my Envato Tuts+ instructor page to see other tutorials I've written, such as Using Social Media to Locate Eyewitnesses, which highlights the APIs of Instagram and Twitter.

Related Links

Tags:

Comments

Related Articles