Patters to deal with big ActiveRecord models
summary
A set of concrete patterns and tradeoffs for shrinking a 675‑line AR model: split into separate models and use ActiveModel form objects for multi‑object signups; extract tagging into a taggable concern versus a lightweight responsibility/role object (decoration) for single rules; introduce gateways for external APIs and service/context objects for coordination to eliminate callback spaghetti. Pros, cons, and costs (indirection, naming collisions, test speed) are compared with examples.
AI-written summary · about
chapters (12)
- 0:00Start
- 0:55Gigantic Models!
- 1:06Low Cohesion
- 8:55Concerns
- 10:58DRYness
- 17:40Responsibilities
- 27:21Avoid callbacks
- 27:46Contexts
- 29:35Lighter tests
- 32:11Rails Way
- 33:39Roles for any business logic
- 35:45Your way?
related talks
33mExperimental Patterns in ActiveRecord
29mActiveRecord, the Repository Pattern, and You
27mDecouple Your Models with Form Objects
35mRails vs. Object Oriented Design
31mWhat Comes After MVC
46mRails as a piece of birthday cake
38mRails hurts, because you're using it wrong. Let's fix that
50mConvenience vs Simplicity
