Properly Factored MVC in Rails Applications
summary
A real refactor of a large Rails app: the stats controller is ~800 lines and one index action is ~200 lines with ~35 instance variables, so code is extracted into a new TagCloud model with a compute method, behavior preserved by a lockdown characterization test that captures raw HTML, tests guarded with Timecop to freeze time, SimpleCov and focused rake tasks (full suite ~17 minutes). Iterative extraction, renaming, and removing duplication shrink the controller while keeping output identical.
AI-written summary · about
chapters (9)
- 0:00Start
- 6:58Data Get from a Controller to a View
- 8:28Controller
- 10:15Refactoring
- 29:18Lockdown Test
- 48:43Recap
- 55:44Isolating the Code
- 1:00:26Embed Classes within Other Classes
- 1:40:33Heroku Performance Workshop
related talks
28mZen and the Art of the Controller
31mWhat Comes After MVC
46mRails as a piece of birthday cake
33mRefactoring Towards Component-based Rails Architectures
33mSo You Want to Start Refactoring?
41mOff the Tracks - Challenging the Rails Mindset
34m"Taming your Rails monolith"
28mRefactoring for Rails - using deodorant to prevent code smells
