DEV Community

Cover image for Rails Main Principles
Rutvik Patel
Rutvik Patel

Posted on • Updated on • Originally published at Medium

Rails Main Principles

Rails Main Principles

Hello Everyone, In this article, we are going to discuss the Main Principles of a popular framework for web development — “Ruby on Rails”. So let’s get started.

Rails Principles

Rails Principles Poster Designed By Rutik Patel(me)



This article is divided into the sections listed below:

  1. What is Ruby on Rails?

  2. Rails Principles

Let’s start by reviewing Ruby on Rails’ foundational concepts.

What is Ruby on Rails?

Ruby on Rails (RoR), is a server-side web application framework which is written in Ruby. In simpler terms, Rails is a full-stack web development framework. It includes all of the tools you’ll need to build amazing front-end and back-end web applications. It was created by David Hansson in 2004.

Rails can do everything and more, including enqueuing jobs for asynchronous work, storing uploads in the cloud, producing HTML templates, updating databases, sending and receiving emails, maintaining live pages with Web Sockets, and providing solid security protections for conventional assaults.

Rails Principles

The Rails framework is based on two fundamental principles, making it a popular choice among customers and web programmers.

  1. Conventions over Configurations

  2. Don’t Repeat Yourself (DRY)

1. Conventions over Configurations

Many programming language or web frameworks require lots of configuration and it acquire good amount of time. Few web application frameworks, for instance, require many configuration files, each with a variety of options. A developer need to define that a class called “Blogs” and a database table called “blogs” are equivalent.

However, Rails depends on assumptions rather than detailed configuration files. Convention indicates that if a programmer creates a model named “Post”, It will automatically save data to a database table called “posts” without any additional configuration.

It greatly helps in reducing the time and effort required by developers, without compromising development flexibility.

2. Don’t Repeat Yourself (DRY)

“Don’t Repeat Yourself,” commonly abbreviated and known as DRY, is one of the most important principle in application development. The primary goal of DRY principle is to minimise code duplication or repetition. To illustrate, rails provide a feature of partials which follows this philosophy.

The user can create a partial and write code in that, which will be reused throughout the application as many times as needed without repeating the entire code.

It facilitates developers to producing simpler, user-friendly, manageable, and easier-to-upgrade applications, as well as making it a piece of cake to create sophisticated systems.

Photo by [Kelly Sikkema](https://unsplash.com/@kellysikkema?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)

Photo by Kelly Sikkema - (https://unsplash.com/@kellysikkema)

Top comments (0)