RubyFlow The Ruby and Rails community linklog

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

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in