Ruby on Rails
Ruby on Rails cheat sheet with MVC architecture, Active Record, routing, migrations, controllers, and deployment code examples.
Table of Contents
Getting Started
New Rails Application
Create a new Rails application with various options
Rails Server & Console
Start development server and interactive console
Generators
Model Generator
Generate models with migrations and attributes
Controller Generator
Generate controllers with actions and views
Scaffold Generator
Generate complete CRUD resource with all components
Migration Generator
Generate standalone database migrations
Database & Migrations
Database Commands
Create, migrate, and manage database
Migration Methods
Common methods used in migration files
Routes
Resourceful Routes
RESTful routes with resources
Custom Routes
Define custom routes and root
Controllers
Controller Actions
Common controller patterns and responses
Filters & Callbacks
Before/after/around filters for controller actions
Models & Active Record
Model Associations
Define relationships between models
Validations
Validate model data before saving
Queries & Scopes
Query database with Active Record
Callbacks
Lifecycle hooks for model operations