Description #
Ruby on Rails, often just called Rails, is a full-stack web application framework written in Ruby. It follows the Model-View-Controller (MVC) architecture and emphasizes convention over configuration, making it fast to build and maintain database-backed web applications.
History #
Rails was created by David Heinemeier Hansson (DHH) in 2004 while working on Basecamp. It popularized many modern web development practices, including migrations, RESTful routing, and scaffolding. Rails became a leading framework in the mid-2000s and is still widely used in startups and legacy systems.
Hello World Code #
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
def hello
render html: "Hello, World!"
end
end
# config/routes.rb
Rails.application.routes.draw do
root "application#hello"
end
How to Run #
Option 1: Online
Option 2: Local
Install Rails (Ruby must be installed):
gem install rails
Create a new app:
rails new hello_world
cd hello_world
Replace controller and routes as shown above
Run the server:
rails server
Visit: http://localhost:3000
Key Concepts #
- MVC architecture
- Convention over configuration
- RESTful routing
- Database migrations
- ActiveRecord ORM
- Scaffolding for fast prototyping
- Built-in testing tools
- Gem ecosystem (RubyGems)
- Emphasis on developer happiness
- Default SQLite or PostgreSQL support
Try It Online #
Fun Facts #
- GitHub, Shopify, and Basecamp were built with Rails.
- The phrase “convention over configuration” became popular through Rails.
- Rails inspired the creation of Django (Python) and Laravel (PHP).