Image for post
Image for post
https://visualwebz.com

Ruby on Rails is one excellent way of developing websites. In fact, Ruby on Rails (RoR), is a dynamic programming system that is specifically designed to help one make a website very quickly. It is battle-tested and proven by big web companies such as Twitter, Amazon, twitch and so much more. Everything in Rails is designed to make everything in your life as the developer easier. Unlike other languages, Ruby on Rails makes assumptions for you, helping to cut down on coding time.

Image for post
Image for post
https://visualwebz.com

Basics of Ruby on Rails

RUBY

Ruby is a programming language. It was created 20 years ago by Yukihiro “Matz” Matsumoto. By most measures of programming language popularity. Overall, Ruby ranks among the top ten; usually as tenth (or so) in popularity, though, and largely due to the popularity of Rails. Like Java or the C language, Ruby is a general-purpose programming language, though it is best known for its use in web programming. The Ruby on Rails framework is based upon the MVC design pattern which is a Model View Controller pattern. This design principle divides the work of an application into three separate layers. Where the presentation to the client is handled by views, the database communication is handled by the model layer, and the controller is used for communication between these two layers, which handles requests from clients and users.

RAILS

Rails is a built open ruby language which is a dynamic programming language. So, the basic advantage of rails comes from the usage of this language because ruby makes life easier to do metaprogramming. Why do you ask? Well, one of the top three things Rails excels through MVC (Model View Controller), Convention, Over Configuration, and DRY (Don’t Repeat Yourself).

HISTORY

Rails came about in 2003 by David Heinemeier Hansson. Who extracted Ruby on Rails from his work on the project management tool at the web application company Basecamp.

In August 2006, the framework reached a milestone when Apple announced that it would ship Ruby on Rails with Mac OS X v10.5 “Leopard”. which was released in October 2007.

Rails version 2.3

Version 2.3 was released on March 15, 2009, with major new developments in templates, engines, Rack, and nested model forms. Templates enable the developer to generate a skeleton application with custom gems and configurations. Engines give developers the ability to reuse application pieces complete with routes, view paths, and models. The Rack webserver interface and Metal allow one to write optimized pieces of code that route around the Action Controller.

Rails 3.0 release

On December 23, 2008, Merb, another web application framework, was launched, and Ruby on Rails announced it would work with the Merb project to bring “the best ideas of Merb” into Rails 3, ending the “unnecessary duplication” across both communities. Merb was merged with Rails as part of the Rails 3.0 release.

Rails 3.1

This version was released on August 31, 2011, featuring Reversible Database Migrations, Asset Pipeline, Streaming, jQuery as default JavaScript library, and newly introduced CoffeeScript and Sass into the stack.

Rails 3.2

Version 3.2 was released on January 20, 2012, with a faster development mode and routing engine (also known as Journey engine), Automatic Query Explain, and Tagged Logging. Rails 3.2.x is the last version that supports Ruby 1.8.7. Rails 3.2.12 supports Ruby 2.0.

More Releases

  • 4.0 was released on June 25, 2013, introducing Russian Doll Caching, Turbolinks, Live Streaming as well as making Active Resource, Active Record Observer, and other components optional by splitting them as gems.
  • 4.1 was released on April 8, 2014, introducing Spring, Variants, Enums, Mailer previews, and secrets.yml.
  • 4.2 was released on December 19, 2014, introducing Active Job, asynchronous emails, Adequate Record, Web Console, and foreign keys.
  • 5.0 was released on June 30, 2016, introducing Action Cable, API mode, and Turbolinks 5.
  • 5.1 was released on April 27, 2017, introducing Javascript integration changes (management of JavaScript dependencies from NPM via Yarn, an optional compilation of JavaScript using Webpack, and a rewrite of Rails UJS to use vanilla JavaScript instead of depending on jQuery), system tests using Capybara, encrypted secrets, parameterized mailers, direct and resolved routes, and a unified form_with helper replacing the form_tag/form_for helpers

MVC

Image for post
Image for post

MVC or Model View Controller models are ruby classes that handle the business logic and do the heavy lifting of the application or in simple terms the flow of your application. The Ruby on Rails framework is based upon an MVC design pattern which is a Model View Controller pattern. This design principle divides the work of an application into three separate layers where the presentation to the client is handled by views, the database communication is handled by the model layer, and the controller is used for communication between these two layers and handles requests from clients and users.

  • Models — are Ruby classes that handle the business logic and o the heavy lifting of the application. They talk with the database and validate data for you.
  • Views — is what you the developer will physically see in the front end. They are templated from the model that renders your application. Basically, it's what the users see and interact with.
  • Controller — sits in between Model and View that handles requests and initiates changes into your model. A server-side component of Rails that responds to external requests from the webserver to the application, by determining which view file to render.

The controller may also have to query one or more models for information and pass these on to the view. For example, “in an airline reservation system, a controller implementing a flight-search function would need to query a model representing individual flights to find flights matching the search, and might also need to query models representing airports and airlines to find related secondary data”. The controller might then pass some subset of the flight data to the corresponding view, which would contain a mixture of static HTML and logic that used the flight data to create an HTML document containing a table with one row per flight.

A controller may provide one or more actions. In Ruby on Rails, an action is typically a basic unit that describes how to respond to a specific external web-browser request. Also, note that the controller/action will be accessible for external web requests only if a corresponding route is mapped to it. Rails encourage developers to use RESTful routes, which include actions like: create, new, edit, update, destroy, show, and index. These mappings of incoming requests/routes to controller actions can be easily set up in the routes.RB configuration file.

CONVENTION OVER CONFIGURATION

Also known as coding by convention, this software design paradigm is used by software frameworks that attempt to decrease the number of decisions that a developer using the framework is required to make without necessarily losing flexibility. The concept was introduced by David Heinemeier Hansson to describe the philosophy of the Ruby on Rails web framework but is related to earlier ideas like the concept of “sensible defaults” and the principle of least astonishment in user interface design. The phrase essentially means a developer only needs to specify unconventional aspects of the application. For example, if there is a class called “Sales” in the model, the corresponding table in the database is called “sales” by default. It is only if one deviates from this convention, such as calling the table “product sales”, that one needs to write code regarding these names.

When the convention implemented by the tool matches the desired behavior, it behaves as expected without having to write configuration files. Only when the desired behavior deviates from the implemented convention is the explicit configuration required.

DRY PRINCIPLE:

The DRY principle is stated as “Every piece of knowledge must have a single, unambiguous, authoritative representation within a system” To help to maintain clean code, Rails follows the idea of DRY, an acronym for Don’t Repeat Yourself. The idea behind it is simple: whenever possible, re-use as much code as possible rather than duplicating similar code in multiple places. This reduces errors, keeps your code clean, and enforces the principle of writing code once and then reusing it. This also helps lead to an API driven structure whereby internal methods are hidden and changes are achieved through passing parameters in an API fashion.

WHO USES RUBY ON RAILS

Many of the most used websites in the global platform use the Ruby on Rails language

Image for post
Image for post

for its ability to make linear layouts that make the “view” and interface of the website approachable to many consumers throughout the world. For example, SoundCloud which is the largest digital audio sharing platform on the web due to its linear pattern is easy to follow in both web and mobile applications. Therefore, designing the UI (User Interface) of an application/website becomes trivial regardless of the many added elements one needs to put into their project.

Image for post
Image for post

The most iconic use/release of Ruby on Rails is none other than Twitter, for it was immediately released by Jack Dorsey on to the web in 2005 without any promos or rumored development time. It was also one of the very first websites built on Ruby and Rails.

Other notable websites made on Ruby on Rails are www.airbnb.com, www.square.com, and www.groupon.com. The best thing about Ruby on Rails is a very predictable application framework and according to many sources, it is very easy to learn much less use. Most people who can use Ruby on Rails are people who have had previous web experience building websites that interact with databases, for they will be not be creating and recreating site functionality from scratch. Especially those who are concerned with best practices, web standards, and switching to work with a framework instead of writing everything from scratch all the time.

Lastly, it is perfect for people who are not afraid of the command line. With Rails, there’s going to be a lot with working on the command line, more so than PHP, and ready to embrace the entire experience.

WHY RUBY ON RAILS:

  • The process of programming is much faster than with other frameworks and languages, partly because of the object-oriented nature of Ruby and the vast collection of open source code available within the Rails community.
  • The Rails conventions also make it easy for developers to move between different Rails projects, as each project will tend to follow the same structure and coding practices.
  • Good for rapid application development (RAD), as the framework makes it easy to accommodate changes.
  • Ruby code is very readable and mostly self-documenting. This increases productivity, as there is less need to write out separate documentation, making it easier for other developers to pick up existing projects.
  • A strong focus on testing and have good testing frameworks.
  • Rails and most of its libraries are open sources, so unlike other commercial development frameworks, there are no licensing costs involved.

POTENTIAL RAILS PROBLEMS AND LIMITATIONS AND HOW TO OVERCOME THEM:

  • Not all website hosts can support Rails

While it is true that not all web hosts support Rails, this is primarily because it can be more resource-intensive than PHP, a fact which deters low-end shared-hosting providers. However, this is by no means a deal-breaker, and of course, Rails-friendly hosts do exist, for example, Heroku and EngineYard.

Alternatively, you can host your Rails application on a Virtual Private Server (VPS) with Amazon EC2, Rackspace, or Linode. You will then have full control over the server and can allocate sufficient resources for your application.

  • Java and PHP are more widely used, and there are more developers in these languages

The number of Ruby developers is growing year on year as more people switch to it from other programming languages. One of the main differences between Ruby and other communities is the amount of open source code (gems) that is publicly available, as of writing there are 63,711 gems that you can use to enhance your application.

  • Performance and Scalability

There have been concerns that Rails applications are not as fast as Java or C, which is true, but for the majority of applications, it is fast enough. There are plenty of high profile organizations that rely on Rails to power their sites including Airbnb, Yellow Pages, Groupon, Channel 5, and Gov.UK.

Ruby Website Developers

There are many website developers available that can help maintain an existing website built on Ruby on Rails as well as help your business transition to other platforms. It's always a good idea to check how comfortable they are with this technology.

First appeared on Visualwebz.com a Seattle Web Design Agency

Written by

A Seattle web design and online marketing agency that delivers high-end websites. A passion for web development and SEO.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store