A custom design pattern for building dynamic ActiveRecord queries by Justin Daniel
The pain is familiar to long-time developers of enterprise Rails applications. Database queries through ActiveRecord are an essential part of our application. And making these queries performant, dynamic, and readable is hard. We can solve the above problems. With the right abstractions we can write code that composes queries that are performant, dynamic, and readable. Our approach uses a domain specific language built on top of ActiveRecord that you can adapt to your own application. We do not need a whole new library or framework. We just need query objects and builders.
April 24, 2023