Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • jQuery
  • AngularJS
  • ReactJS
  • Next.js
  • React Native
  • NodeJS
  • Express.js
  • MongoDB
  • MERN Stack
  • PHP
  • WordPress
  • Bootstrap
  • Tailwind
  • CSS Frameworks
  • JS Frameworks
  • Web Development
Open In App
Next Article:
Ruby on Rails Introduction
Next article icon

Ruby on Rails Introduction

Last Updated : 30 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Ruby on Rails or also known as rails is a server-side web application development framework that is written in the Ruby programming language, and it is developed by David Heinemeier Hansson under the MIT License. It supports MVC(model-view-controller) architecture that provides a default structure for database, web pages, and web services, it also uses web standards like JSON or XML for transfer data and HTML, CSS, and JavaScript for the user interface. It emphasizes the use of other well-known software engineering pattern and paradigms like:

  • Don't Repeat Yourself (DRY): It is a principle of software development to reducing the repetition of information or codes.
  • Convention Over Configuration (CoC): It provides many opinions for the best way to do many things in a web application.

Ruby on Rails was first released in July 2004 but until February 2005 did not share the commit rights. In August 2006, it would ship Ruby on Rails with Mac OS X v10.5 "Leopard". Ruby on Rail's latest version(Rail 5.0.1) released on December 21, 2016. Action cable, Turbolinks 5, and API mode Introduced in this version.

Why Ruby on Rails?

  • It allows you to launch a faster web application.
  • Saves your money by using the Ruby on Rails framework.
  • Helps us with maintaining and avoiding problems with stuff migration.
  • Ruby on Rail Framework makes our app faster and safer.
  • We can easily update our app with the latest functionality.
  • It uses Metaprogramming techniques to write programs.

Where to use Ruby on Rails?

You can use Ruby on Rails application in various area of web development like in a long term project which needs large transformation, or in the project that has heavy traffic, or to develop a short prototype or MVPs, or in a project that requires wide range of complex functions, etc.

Feature of Ruby on Rails

As we know that most of the languages like Java, HTML, CSS, etc. do not cover the front end and back end. They either only for the back end or for the front end but Ruby on Rails is used for both front end back end, it is like a complete package to develop a web application. Some important features of Ruby on Rails are:

  • Model-view-controller Architecture: Ruby on Rails used MVC architecture, and it contains three components, i.e., model, view, and controller. Here, the model is used to maintain the relationship between object and database, the view is templates that are used to build the data users for web applications, and the controller is used to merge model and view together. MVC is generally used for developing user interfaces that divide the data into three interconnected components so that it can separate the internal representation of the information from the way it presents to and get from the user. 
Rails-MVC-Architecture
Model-view-controller Architecture
  • Active Records: The active record framework is introduced in Ruby on Rails. It is a powerful library that allows the developer to design the database interactive queries.
  • Built-in Testing: Ruby on Rails provides its own set of tests that will run on your code. It will save time and effort.
  • Programming Language: This syntax of Ruby on Rails is simple because the syntax of the Ruby programming language is close to English, so it is always easier to structure your thinking and writing it into code.
  • MetaProgramming: Ruby on rails uses the metaprogramming technique to write programs.
  • Convention over configuration: In Ruby on Rails, a programmer can only specify the unconventional aspects of the application. 
  • Scaffolding: Ruby on rails provides a scaffolding feature in which the developer is allowed to define how the application database works. After defining the work of the application database the framework automatically generates the required code according to the given definition. This technique creates interfaces automatically.

for more: Features of Ruby on Rails

Advantages of Ruby on Rails

  • Tooling: Rails provides tooling that helps us to deliver more features in less time.
  • Libraries: There's a 3rd party module(gem) for just about anything we can think of.
  • Code Quality: Ruby code quality significantly higher than PHP or NodeJS equivalents.
  • Test Automation: The Ruby community is big into and test automation and testing.
  • Large Community: Ruby is large in the community.
  • Productivity: Ruby is incredibly fast from another language. Its productivity is high.

Disadvantages of Ruby on Rails

  • Runtime Speed: The run time speed of Ruby on Rails is slow as compare to Node.Js and Golang.
  • Lack of Flexibility: As we know that Ruby on Rails is ideal for standard web applications due to its hard dependency between components and models. But when it comes to adding unique functionality and customization in apps it is challenging.
  • Boot Speed: The boot speed is also a drawback of ROR. Due to the dependence upon the number of gem dependencies and files, it takes some time to start which can obstruct the developer performance.
  • Documentation: To find good documentation is hard for the less popular gems and for libraries that make heavy use of mixins.
  • Multithreading: Ruby on Rails supports multithreading, but some IO libraries do not support multithreading because they keep hold of the global interpreter lock. So it means if you are not careful enough, your request will get queued up behind the active requests, and you will face performance issues.
  • Active Record: Due to the access use of Active records in the ROR and hard dependency, the domain becomes tightly coupled to your persistence mechanism.

Example:

To create a rails application you need to follow the following steps:

Step 1: Open a terminal and write the following command. This command creates an application with the name 'myFirstProject'. 

rails new myFirstProject

Step 2: Now we move into our application directory.

cd myFirstProject 

Here, myFirstProject contains these files. 

Step 3: Now we create a rails server using the following command.

bin/rails s 

or 

bin/rails server

By default, the rails server uses port 3000. If you want to change the port number we can use the following command:

rails server -p portNumber  

Now open the browser and open http://localhost:3000/. If your server works properly then you will get this page.

Step 4: Open another terminal and move to myFirstProject directory. Now we create a controller named 'sample' for our home page.

rails generate controller sample

Step 5: Now we add an index page. So open sublime text and write the following HTML code and save the file with name index.html.erb, and in location: /myFirstProject/app/views/sample/index.html.erb.

<h3>My first ruby on rails application</h3>

Step 6: After creating index page, we need to route the ruby on rails to this page. So for that open routes.rb file which is present in location: /myFirstProject/config/routes.rb. Now write the following line in the routes.rb file

root'sample#index'

Step 7: Now refresh the browser window to see the final output.


Next Article
Ruby on Rails Introduction

D

DivyaPareek
Improve
Article Tags :
  • Web Technologies
  • Ruby
  • Frameworks
  • RubyonRails

Similar Reads

    Layouts in Ruby on Rails
    In Ruby on Rails, a layout is like a template that wraps around your pages. This will give all your web pages an understandable structure so that the header, footer, and the rest of the design look the same on every page. Rails has a default layout named application.html.erb, which can be found in t
    6 min read
    Ruby Programming Language (Introduction)
    Ruby is a pure Object-Oriented language developed by Yukihiro Matsumoto (also known as Matz in the Ruby community) in the mid 1990’s in Japan. Everything in Ruby is an object except the blocks but there are replacements too for it i.e procs and lambda. The objective of Ruby's development was to make
    4 min read
    Ruby on Rails - Controller
    In Ruby on Rails, a Controller manages the flow of data between the Model and the View. When a user makes a request, the Controller decides what data to fetch or update, and which view to display. Think of it as the middleman that takes user input, processes it with the help of the Model, and sends
    6 min read
    Ruby on Rails Filters
    In the web development landscape, efficiently managing request-response cycles is paramount. Ruby on Rails, a prominent web application framework, provides a powerful feature called "filters" within its MVC architecture. Filters enable developers to execute specific code at defined points during the
    2 min read
    Ruby on Rails - Active Job
    Active Job is a framework in Ruby on Rails designed to handle background jobs. Background jobs are tasks that can be processed asynchronously, allowing your application to remain responsive while performing time-consuming operations behind the scenes. Active Job makes it easy to manage these tasks,
    9 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences