DEV Community

Patchy from FireHydrant for FireHydrant

Posted on

Flexible Ruby on Rails Reader Objects

Rails and ActiveRecord are great at providing a simple interface for retrieving information from a database. With a few simple characters, I can retrieve all of my users with User.all. While this simplicity is great, it breaks down when you want to start doing more advanced queries such as paginated results, filtered records, etc. Typically you start to see Rails models get a swath of scope definitions to implement this, but over time this just becomes incredibly difficult to maintain. This also gets hairy when you want to use the same reader object for different types of requests (API vs UI for example).

Read the full post here

This post was originally published on the FireHydrant Blog on May 1, 2019 by Robert Ross.

Top comments (0)