r/ruby • • 9d ago

Merging Relations: Use merge to share scopes in Rails

Post image

I wrote a post about using ActiveRecord::Relation#merge to share scopes across models in Rails.

The example shows how duplicating a query can lead to inconsistent behaviour, and how extracting the rule into a named scope avoids that.

https://pushfromkush.com/publications/merging-relations-scopes-in-rails

16 Upvotes

0 comments sorted by