An Intervention for ActiveRecord
summary
ActiveRecord contains real, concrete warts: ~16,000 lines, hundreds of methods and surprising behaviors you must know before you touch models. Expect specifics: init_with/instantiate bypasses initialize so hydrated records differ from new ones; associations sometimes auto-persist depending on persisted state; predicate_builder forces known table names which breaks dynamic joins; inverse_of fixes object identity and prevents validation surprises. Practical fixes and tools discussed include squeal, ransack, meta_where and rescuing DB unique-constraint errors instead of trusts in validates_uniqueness_of.
AI-written summary · about
chapters (16)
- 0:00Start
- 2:48Active Record has the primary advantage of simplicity. It's easy to build Active Records, and they are easy to understand.
- 3:0057 ancestors 559 class methods 352 instance methods
- 3:50ActiveRecord has issues
- 4:08NOBODY UNDERSTANDS ACTIVERECORD
- 4:32YOU ARE NOT THE EXCEPTION
- 5:52MAGIC REQUIRES CONVENTIONS
- 6:26OBJECT INITIALIZATION
- 19:17VALIDATES UNIQUENESS OF
- 23:35DEFAULT SCOPE
- 36:14INHERITANCE AND SUPER
- 38:06ACTIVERECORD WORKS WELL ENOUGH
- 38:23INTENTIONALLY
- 39:24ACTIVERECORD IS LEGACY
- 39:35ACTIVERECORD IS OUR LEGACY
- 40:20PARTICIPATE IN THE DISCUSSION
related talks
27mRediscovering ActiveRecord
40mTricks That Rails Didn't Tell You About
29mActiveRecord, the Repository Pattern, and You
33mExperimental Patterns in ActiveRecord
41mCurmudgeon: An Opinionated Framework
38mRails hurts, because you're using it wrong. Let's fix that
31mActiveSupport and ActiveModel
26mDon't Rewrite Your Framework
