A Ruby gem that efficiently plucks attributes from nested ActiveRecord associations without loading full records.
DeepPluck is a Ruby gem that extends ActiveRecord's pluck functionality to work with nested associations. It solves the problem of inefficient data extraction by allowing developers to fetch specific attributes from related models without loading entire records into memory, dramatically improving performance for complex data serialization tasks.
Rails developers working with complex data relationships who need to optimize API responses or data exports, particularly those experiencing performance issues with ActiveRecord serialization methods.
Developers choose DeepPluck because it provides up to 40x performance improvements over traditional methods like `as_json`, uses a clean and familiar API, and significantly reduces memory overhead when extracting nested data from ActiveRecord associations.
Allow you to pluck attributes from nested associations without loading a bunch of records.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Benchmarks in the README show 4x to 40x speed improvements over as_json by returning raw hash data without instantiating ActiveRecord objects, reducing memory usage.
Uses a syntax identical to ActiveRecord's built-in pluck method, making it easy for Rails developers to adopt without a steep learning curve, as shown in usage examples.
Supports Ruby versions from 2.3 to 3.2 and Rails from 3.2 to 7.2, ensuring compatibility with a broad range of legacy and modern projects per the README.
Offers a more concise and DRY alternative to verbose nested as_json configurations, simplifying code for complex data extraction, as demonstrated in the comparison example.
Only works with ActiveRecord associations, limiting its utility to Rails projects and excluding applications using other ORMs or data layers.
Returns plain hashes instead of ActiveRecord instances, meaning you lose access to model methods, scopes, and callbacks, which can break existing code expecting objects.
The README does not specify support for all association types like polymorphic or has_many :through, potentially leading to gaps in functionality for advanced schemas.