Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Off the Rails: Patterns for fixing fat models, ...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Alexander Clark
April 23, 2019
Technology
350
0
Share
Off the Rails: Patterns for fixing fat models, out-of-controllers, and other Rails problems
Alexander Clark
April 23, 2019
More Decks by Alexander Clark
See All by Alexander Clark
Docker: What It Is and Why You Should Care
alexanderclark
0
370
Building with Rack
alexanderclark
2
360
Other Decks in Technology
See All in Technology
プロンプトエンジニアリングを超えて:自由と統制のあいだでつくる Platform × Context Engineering
yuriemori
0
170
ふりかえりがなかった職能横断チームにふりかえりを導入してみて学んだこと 〜チームのふりかえりを「みんなで未来を考える場」にするプロローグ設計〜
masahiro1214shimokawa
0
340
あるアーキテクチャ決定と その結果/architecture-decision-and-its-result
hanhan1978
2
570
ログ基盤・プラグイン・ダッシュボード、全部整えた。でも最後は人だった。
makikub
5
1.4k
DevOpsDays Tokyo 2026 見えない開発現場を、見える投資に変える
rojoudotcom
2
160
60分で学ぶ最新Webフロントエンド
mizdra
PRO
3
770
DevOpsDays2026 Tokyo Cross-border practices to connect "safety" and "DX" in healthcare
hokkai7go
0
120
OBI+APMでお手軽にアプリケーションのオブザーバビリティを手に入れよう
kenshimuto
0
180
ZOZOTOWNリプレイスでのSkills導入までの流れとこれから
zozotech
PRO
4
3.3k
さくらのクラウドでつくるCloudNative Daysのオブザーバビリティ基盤
b1gb4by
0
150
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
6
74k
Bluesky Meetup in Tokyo vol.4 - 2023to2026
shinoharata
0
150
Featured
See All Featured
Building Applications with DynamoDB
mza
96
7k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
800
Large-scale JavaScript Application Architecture
addyosmani
515
110k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
300
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
140
Faster Mobile Websites
deanohume
310
31k
First, design no harm
axbom
PRO
2
1.2k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
120
HDC tutorial
michielstock
1
610
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
120
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.2k
Transcript
Off the Rails Patterns for fixing fat models, out-of-controllers, and
other Rails problems
What I’m about to tell you is wrong.
YMMV
MVC
View Controller Model
3 Tier Architecture
Business Logic Presentation Data
Business Logic Presentation Data
Business Logic Presentation Data View Controller Model
Business Logic Presentation Data View Controller Model
View Controller Model Business Logic Presentation Data
None
None
None
View Controller Model
Model Service View Controller
Business Logic Presentation Data
Business Logic Presentation Data
Business Logic Presentation Data Service
None
None
Controller Rule of Thumb A Controller May Contain: • Public
REST methods • Private before_action setters • Private strong params method
Models
Business Logic Presentation Data View Controller Model
Business Logic Presentation Data View Controller Model
Business Logic Presentation Data View Controller Model Repository
None
Business Logic Presentation Data View Controller Validator Model
None
None
None
None
–Sandi Metz “duplication is far cheaper than the wrong abstraction”
YAGNI
Bonus Tip
None
None
Thanks for Listening Alexander Clark atheclark alexander-clark.com alexander-clark
Further reading • https://codeclimate.com/blog/7-ways-to-decompose-fat- activerecord-models/ • Patterns of Enterprise Application
Architecture (Fowler) • Domain Driven Design (Evans) • All the Little Things (Metz) https://www.youtube.com/ watch?v=8bZh5LMaSmE • Ruby Object Mapper https://rom-rb.org/
Questions?