Scoped Associations in Rails
I’ve never thought that ActiveRecord associations could be used as scopes until last week. I couldn’t find a step-by-step explanation, so I did a quick write up about how one can scope associations in Rails.
Some benefits: 👀 Make your code much more readable (stylish, even) ✂ DRY things up ⚡️ Preload your scopes and remove your N+1 queries
Post a comment