Skip to content

Ror Installation

DodaTech 3 min read

title: Ruby on Rails Installation — Complete Guide to Setup and Development description: 'Learn Ruby on Rails installation: RVM/rbenv for Ruby version management, Ruby installation, Rails gem, database setup, first project, and development environment configuration.' date: 2026-06-28 lastmod: 2026-06-28 weight: 12 tags: [backend, ror]


Installing Ruby on Rails requires setting up Ruby (via rbenv or RVM), the Rails gem, a database (SQLite for development, PostgreSQL for production), and configuring the development environment.

## What You'll Learn

By the end of this tutorial, you'll install Ruby with a version manager, install Rails, configure a database, create your first Rails project, and set up an editor for Rails development.

## Real-World Use

A team uses rbenv to standardize on Ruby 3.3 across 10 developers. Each developer runs `rbenv install 3.3.0` and `gem install rails` to get identical environments.

## Installation Learning Path

```mermaid
flowchart LR
  A[Introduction] --> B[Installation]
  B --> C[MVC]
  C --> D[Routing]
  D --> E[Controllers]
  B --> F{You Are Here}
  style F fill:#f90,color:#fff

Install Ruby with rbenv

# macOS
brew install rbenv ruby-build
# Ubuntu/Debian
sudo apt update
sudo apt install rbenv ruby-build
# Initialize rbenv
rbenv init
# Add to ~/.zshrc or ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
source ~/.zshrc

# Install Ruby
rbenv install 3.3.0
rbenv global 3.3.0
ruby --version
Expected output:
ruby 3.3.0 (2023-12-25 revision ...) [x86_64-linux]

Install Rails

# Install Rails gem
gem install rails --no-document
rails --version
Expected output:
Rails 8.0.0

Create Your First App

# Default with SQLite
rails new myapp

# With PostgreSQL
rails new myapp --database=postgresql

# With MySQL
rails new myapp --database=mysql

# Minimal (skip unused components)
rails new myapp --skip-action-mailer --skip-action-text --skip-active-storage

Database Configuration

# config/database.yml (PostgreSQL)
default: &default
  adapter: postgresql
  encoding: unicode
  pool: 5

development:
  <<: *default
  database: myapp_development
  username: <%= ENV["DB_USERNAME"] %>
  password: <%= ENV["DB_PASSWORD"] %>

test:
  <<: *default
  database: myapp_test

production:
  <<: *default
  database: myapp_production
  url: <%= ENV["DATABASE_URL"] %>

Editor Setup

# VS Code extensions
code --install-extension rebornix.Ruby
code --install-extension wingrunr21.vscode-ruby
code --install-extension endormi.ruby-syntax

Common Mistakes

1. Using System Ruby

System Ruby is managed by the OS package manager and is usually outdated. Use rbenv or RVM for version control.

2. Installing Gems with sudo

Running sudo gem install causes permission issues. Use a Ruby version manager that installs gems in user space.

3. Forgetting to Start the Database

PostgreSQL must be running: brew services start postgresql or sudo service postgresql start.

4. Wrong Ruby Version

A project's .ruby-version file specifies the required Ruby version. Use rbenv to install and activate it.

5. Not Installing Node.js/JavaScript Runtime

Rails requires a JavaScript runtime for the asset pipeline. Node.js is the standard choice.

Practice Questions

1. Why use a Ruby version manager?

Multiple projects may need different Ruby versions. rbenv/RVM switch between versions per project.

2. What is the difference between SQLite and PostgreSQL?

SQLite is file-based (development only). PostgreSQL is a production-grade client-server database.

3. How do I specify which database to use for a new Rails app?

Use --database=postgresql or --database=mysql when running rails new.

4. What is the Gemfile.lock file?

Records exact gem versions installed. Ensures consistent environments across installations.

5. Challenge: Install Ruby 3.3, Rails 8, create a PostgreSQL-backed app, and run the server.

rbenv install 3.3.0 && rbenv global 3.3.0
gem install rails
rails new my_app --database=postgresql
cd my_app && rails db:create && rails server

FAQ

Should I use rbenv or RVM?

rbenv is simpler and more lightweight. RVM has more features (gemsets). Both are widely used.

Do I need a database for development?

SQLite comes built-in with Rails and needs no setup. PostgreSQL requires installation and a running service.

What is the difference between Rails 7 and Rails 8?

Rails 8 adds solid_queue, solid_cache, and improved Hotwire integration. Check the official release notes.

How do I troubleshoot installation issues?

Check the Rails guides, run gem install rails --verbose, and search for error messages on Stack Overflow.

Can I use Docker for Rails development?

Yes. Docker provides consistent environments. Use Dockerfile and docker-compose for Rails + PostgreSQL.

Mini Project: Verify Your Rails Setup

Create a new Rails app, start the server, and open it in the browser.

rails new hello_rails
cd hello_rails
rails generate controller home index
# Edit config/routes.rb: root "home#index"
rails server
# Open http://localhost:3000

What's Next

Ruby on Rails MVC Ruby on Rails Routing

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro