Learn RUBY-ON-RAILS with Real Code Examples
Updated Nov 25, 2025
Installation Setup
Install Ruby (3.x+ recommended)
Install Rails via `gem install rails`
Create new project: `rails new project_name`
Navigate to project directory and install dependencies with Bundler
Run development server: `rails server`
Environment Setup
Install Ruby 3.x+
Install Rails gem
Set up database (PostgreSQL/MySQL/SQLite)
Install dependencies via Bundler
Run development server locally
Config Files
config/routes.rb - routes definition
config/application.rb - app configuration
app/models/ - models
app/controllers/ - controllers
app/views/ - templates
Cli Commands
gem install rails
rails new project_name
rails server
rails generate scaffold
rails db:migrate
Internationalization
Built-in I18n support for multiple languages
Translate views and messages
Locale-specific formatting for dates/numbers
UTF-8 encoding by default
Supports pluralization and fallback locales
Accessibility
Templates can include semantic HTML and ARIA
Forms and validation messages accessible
Supports multiple locales via I18n
Middleware can enforce security headers
Screen reader compatibility depends on templates
Ui Styling
ERB or Haml templates
CSS/Sass/JS assets via asset pipeline
Supports front-end frameworks
Dynamic content rendered in views
Minimal default styling
State Management
Stateless HTTP requests
Session management via cookies or server-side sessions
Persistent data via database
Caching for performance
Authentication/authorization manage user state
Data Management
Active Record ORM for database operations
Migrations for schema changes
Serialize JSON for APIs
Use caching layers for frequent queries
Integrate with external services as needed