Candy on Rails: Polymorphism & Rails 5
summary
Rails 5 polymorphism is demonstrated with a candy shop app that models goodies and many package types; examples show the SQL pattern of package_type and package_id and Rails 5βs change where belongs_to optional: true is often required. The demo uses has_many :through with explicit source and source_type, converts repeated package logic into a use a concern to DRY code, and warns that polymorphism hides complexity so it should be added when models are truly distinct.
AI-written summary Β· about
chapters (5)
- 0:00Start
- 2:18Polymorphism
- 10:31Things To Consider
- 12:26Things To Consider When Introducing Polymorphism
- 19:45Use Case
related talks
35mRails vs. Object Oriented Design
39mExploring Rails anti-patterns
46mRails as a piece of birthday cake
33mRails is Just Ruby
40mTricks That Rails Didn't Tell You About
34mRails 5 Features You Haven't Heard About
42mPowerful Rails Features You Might Not Know
41mOff the Tracks - Challenging the Rails Mindset
