Overview of Ruby on Rails Architecture

Sravan Cynixit
4 min readJan 13, 2020

Ruby on Rails is a popular Web Development framework, and it has improved Ruby language itself. The main aim of Ruby on Rails is, to free the developer from handling technology problems, and concentrate on solving business issues.

Ruby on Rails uses the Model View Controller or MVC architectural pattern. It also follows the convention over configuration rule, which is also known as Coding by convention. This means, that it has already taken a few decisions for you and you don’t have to worry about those things until you follow ROR conventions. More Additional Information At Ruby On Rails Online Training

Ruby on Rails follows the MVC architecture pattern, to increase the performance of the application. First, let us try to understand MVC Architecture. This architecture is the basis for structuring our web applications.

Model — The model contains the business logic of the application, and rules to modify the data. In Ruby on Rails, they handle the interaction with related elements in the database. They indicate the data in the database and perform accurate verifications.

View — It maintains the view display logic. It indicates the user interface. In RoR, the view is the HTML files that have Ruby code. The enclosed Ruby code, in the HTML, is very simple with loops and conditionals.

Controller — It handles the application flow. The controller communicates with views and models. The requests that are coming from the browsers are processed, by the controllers. These controllers process the data, from models and forward it to the views for presentation.

Ruby on Rails architecture is based on the MVC architecture. So, let us see Ruby on Rails architecture. There are six basic ROR architecture components.

  1. Models

Models are an important component of our business. Models represent our business domain, in the Ruby language. In RoR, the models act as the interface to our continuous storage.

They provide methods to move the memory-resident state of a model case, in the database. For instance, ‘order.save’ may store an order representation, into the related database table.

In MVC architecture, Models are not web applications, but we can do many things using Models only. For instance, if we start the rails console session, then we can access the models of their application and can perform, some work with data management.

2. Ruby on Rails server

The RoR server represents a web server and is an executable web server. We can use it, to receive requests from the browser. It stays on an IP and a port.

When we start developing, then Rails server begins on our local system and receives requests on port 3000, so that we can get it with http://0.0.0.0:3000/ web address.

Rails server uses MVC architecture, receives the request and assigns, the processing to different components that it made of. It can also write useful logs, in the log folder.

3.Routes

The routes indicate, which URL directs our application and which part of code has to manage related requests.

4. Controllers and their Actions

The controller manages a request, using one of its actions. Every Controller is a Ruby class, and its actions are public methods. Actions have to create the data, that will be used in the HTML sent back as a reaction to the HTTP request.

They perform that response using the models, to get data from the database or perform domain-related calculations, and operations. By giving the objects that are used by the view, using the HTML rendering technique, that follows the continuous cycle of request handling.

To get in-depth knowledge on Ruby, enroll for live free demo on Ruby Certification

5. Views

Views inform the Rails about the content of the HTML, which will be sent back to the browser by request. In MVC architecture, Views depend on the data, that will be made by the controller.

Apart from this data, it also requires a layout, which is a part of HTML markup, in which view will be present. So, various views might use the same layout.

Generally, the layout contains the content which is common to various views, and it encloses the view content.

6. Assets

Generally, assets are CSS code, JavaScript code, and other media like images. The view text enclosed in the layout is sent to the browser, that has requested a page. But, an asset is also sent to the browser.

I hope you got an overview of Ruby on Rails Architecture. I will explain about the Action Controllers in RoR, in my next article. Follow my articles to get more updates, on Ruby on Rails.

--

--