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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Alexander Clark
April 23, 2019
Technology
360
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
380
Building with Rack
alexanderclark
2
370
Other Decks in Technology
See All in Technology
大規模環境でどのように監視を実現する?
yuobayashi
1
120
"スキルファースト"で作る、AIの自走環境
subroh0508
1
690
「使われるデータ基盤」を目指してデータアナリストとワークショップをやった話
jackojacko_
2
710
既存プロダクトQAから新規プロダクトQAへ
ryotakahashi
0
180
AWSアップデートから考える継続的な運用改善
toru_kubota
2
360
基礎から解説!Icebergで紐解くSnowflake×Databricks連携の現在地
cm_yasuhara
0
200
コーポレートサイトのアクセシビリティ改善とJIS準拠への実践
lycorptech_jp
PRO
2
120
TypeScript で Platform SDK を作る技術
toiroakr
1
120
A Harness for Behaviour: how to get AI to generate code that does what we intend, or "TDD in the age of AI"
xpmatteo
0
180
障害対応のRunbookは作った、でも本当に動くの? AWS FIS で EKS の AZ 障害を再現してみた
tk3fftk
0
130
シンデレラなんかになりたくない!ガラスの靴が割れた時代にどう歩く?
nomizone
0
140
実践 TanStack Start ― 新規プロダクトを開発して確立した、サーバーとクライアント境界の設計パターン / Practical TanStack Start Server-Client Boundary Patterns
kaminashi
2
230
Featured
See All Featured
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
460
Unsuck your backbone
ammeep
672
58k
Technical Leadership for Architectural Decision Making
baasie
3
370
Measuring & Analyzing Core Web Vitals
bluesmoon
9
830
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
61
44k
Speed Design
sergeychernyshev
33
1.7k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
300
sira's awesome portfolio website redesign presentation
elsirapls
0
250
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
380
4 Signs Your Business is Dying
shpigford
187
22k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
200
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?