iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

Bootcamp

Ruby + Rails one-day bootcamp: scaffold, MVC, ActiveRecord, Action Mailer, tests, deploy.

Ruby — Rails bootcamp

EXAMPLE
# ===== 0-15 min: install =====
# Use rbenv or asdf to install Ruby 3.3+
brew install rbenv
rbenv install 3.3.0
rbenv global 3.3.0

gem install rails

# ===== 15-30 min: scaffold =====
rails new shop --database=postgresql
cd shop
bin/rails db:create

# Generate scaffolding:
bin/rails generate scaffold Product name:string price:decimal description:text
bin/rails db:migrate

bin/rails server
# http://localhost:3000/products

# ===== 30-60 min: explore the MVC =====
# Models: app/models/product.rb
class Product < ApplicationRecord
  validates :name, presence: true
  validates :price, numericality: { greater_than_or_equal_to: 0 }

  scope :recent, -> { order(created_at: :desc).limit(20) }
end

# Controllers: app/controllers/products_controller.rb (auto-generated)

# Views: app/views/products/*.html.erb

# ===== 60-120 min: associations =====
bin/rails generate model Category name:string
bin/rails generate migration AddCategoryToProducts category:references
bin/rails db:migrate

class Product < ApplicationRecord
  belongs_to :category
end
class Category < ApplicationRecord
  has_many :products, dependent: :destroy
end

# Eager loading (avoid N+1):
Product.includes(:category).recent

# ===== 120-180 min: ActionMailer =====
bin/rails generate mailer OrderMailer

# app/mailers/order_mailer.rb
class OrderMailer < ApplicationMailer
  def confirmation(order)
    @order = order
    mail(to: order.email, subject: 'Your order')
  end
end

# Trigger:
OrderMailer.confirmation(order).deliver_later

# ===== 180-240 min: background jobs =====
# Sidekiq + Redis for production; ActiveJob for the abstraction.

bin/rails generate job ProcessOrder

class ProcessOrderJob < ApplicationJob
  queue_as :default
  def perform(order_id)
    order = Order.find(order_id)
    # ...
  end
end

ProcessOrderJob.perform_later(42)

# ===== 240-300 min: tests =====
# RSpec or Minitest. Rails ships with Minitest:
bin/rails generate model Product   # also creates a test

# test/models/product_test.rb
require 'test_helper'
class ProductTest < ActiveSupport::TestCase
  test 'requires name' do
    product = Product.new(price: 10)
    assert_not product.valid?
  end
end

bin/rails test

# ===== 300-360 min: API mode =====
# For a frontend SPA:
rails new shop --api
bin/rails generate scaffold_controller Product name:string price:decimal

# JSON-only responses; no views.

# ===== 360-420 min: deploy =====
# Modern Rails deploy: Render, Fly.io, Heroku, Railway.
# Or Docker:
# Dockerfile + docker-compose with postgres + redis.
# Run migrations via release command.

# ===== Patterns to internalise =====
# - Convention over configuration
# - Migrations in source control; run on deploy
# - includes / eager_load to avoid N+1
# - Background jobs for anything > 100ms
# - Tests + factories (factory_bot) for confidence

# ===== Pitfalls =====
# - mass-assignment without strong params
# - N+1 queries via .each + association calls
# - Long controllers; extract service objects
# - SQL injection via string interpolation in where()

Why it matters

A one-day Rails bootcamp: scaffold, MVC, associations, mailer, jobs, tests, deploy. The same shape ships small SaaS, internal tools, and side projects. Rails still earns its place when shipping fast matters.

Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.

Example

Example
# 30-day Ruby bootcamp in the lesson body.
Try it Yourself »

Discussion

Loading…