What Rails Does
- MVC — Model, View, Controller architecture
- ActiveRecord — ORM with migrations, validations, associations
- Scaffold — one-command CRUD generation
- Routing — RESTful resource routing
- Action View — ERB/Haml templates
- Action Cable — WebSocket framework
- Active Job — background job abstraction
- Action Mailer — email sending with templates
- Active Storage — file uploads to S3/GCS/Azure
- Turbo + Stimulus — Hotwire for HTML-over-the-wire
- Kamal — deploy Rails anywhere with Docker
- Solid Queue/Cache/Cable — database-backed infrastructure
Architecture
Full MVC with an opinionated project structure. Convention over Configuration means file names, directory layouts, and naming patterns determine behavior. Asset pipeline (Propshaft/Dartsass in Rails 7+) for CSS/JS. Rails 8 introduces Solid trifecta for database-backed queues, caches, and WebSockets.
Self-Hosting
# Production (Rails 8)
KAMAL_REGISTRY_PASSWORD=xxx kamal setup
kamal deploy
# Traditional
bundle exec puma -C config/puma.rb
# Behind Nginx reverse proxyKey Features
- Convention over Configuration
- ActiveRecord ORM
- Scaffold generators
- RESTful routing
- Hotwire (Turbo + Stimulus)
- Action Cable (WebSocket)
- Active Job (background)
- Active Storage (uploads)
- Kamal deployer
- Rails 8 Solid trifecta
- Mature gem ecosystem
Comparison
| Framework | Language | Philosophy | Speed |
|---|---|---|---|
| Rails | Ruby | Convention > config | OK |
| Django | Python | Batteries-included | OK |
| Laravel | PHP | Elegant syntax | OK |
| Phoenix | Elixir | Convention + speed | Fast |
| Spring Boot | Java | Enterprise auto-config | OK |
| Next.js | TypeScript | Full-stack React | Fast |
常见问题 FAQ
Q: Rails 性能? A: Ruby 3.3 + YJIT 让 Rails 比 Ruby 2.x 快 3 倍。Shopify 全球百万商户在 Rails 上跑。性能瓶颈通常在数据库,不在框架。
Q: Rails 7 vs 8? A: Rails 8 推出 Solid Queue(DB-backed 队列,不需要 Redis)、Solid Cache、Solid Cable,简化部署。加上 Kamal deployer,目标是单人全栈开发者也能 deploy anywhere。
Q: Hotwire 是什么? A: Turbo(HTML-over-the-wire 取代 SPA)+ Stimulus(轻量 JS sprinkles)+ Strada(mobile bridge)。用 Rails 写全栈 app 不需要 React 或前后端分离。
来源与致谢 Sources
- Docs: https://guides.rubyonrails.org
- GitHub: https://github.com/rails/rails
- License: MIT