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
Alexander Clark
April 23, 2019
Technology
0
300
Off the Rails: Patterns for fixing fat models, out-of-controllers, and other Rails problems
Alexander Clark
April 23, 2019
Tweet
Share
More Decks by Alexander Clark
See All by Alexander Clark
Docker: What It Is and Why You Should Care
alexanderclark
0
320
Building with Rack
alexanderclark
2
320
Other Decks in Technology
See All in Technology
SDカードフォレンジック
su3158
1
660
持続可能なドキュメント運用のリアル: 1年間の成果とこれから
akitok_
1
250
勝手に!深堀り!Cloud Run worker pools / Deep dive Cloud Run worker pools
iselegant
4
570
エンジニアリングで組織のアウトカムを最速で最大化する!
ham0215
1
260
AZ 名とAZ ID の違いを 何度でも言うよ
miu_crescent
PRO
0
110
AndroidアプリエンジニアもMCPを触ろう
kgmyshin
1
500
3月のAWSアップデートを5分間でざっくりと!
kubomasataka
0
140
Terraform Cloudで始めるおひとりさまOrganizationsのすゝめ
handy
2
210
2025-04-24 "Manga AI Understanding & Localization" Furukawa Arata (CyberAgent, Inc)
ornew
2
300
Notion x ポストモーテムで広げる組織の学び / Notion x Postmortem
isaoshimizu
1
130
Compose におけるパスワード自動入力とパスワード保存
tonionagauzzi
0
150
AWS全冠芸人が見た世界 ~資格取得より大切なこと~
masakiokuda
5
6.5k
Featured
See All Featured
Become a Pro
speakerdeck
PRO
28
5.3k
Into the Great Unknown - MozCon
thekraken
38
1.7k
KATA
mclloyd
29
14k
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.8k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
227
22k
We Have a Design System, Now What?
morganepeng
52
7.5k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
A Tale of Four Properties
chriscoyier
158
23k
4 Signs Your Business is Dying
shpigford
183
22k
Speed Design
sergeychernyshev
29
910
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
23
2.7k
Product Roadmaps are Hard
iamctodd
PRO
52
11k
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?