Active_hash_relation

screenshot of Active_hash_relation
rails

ActiveHash Relation: Simple gem that allows you to run multiple ActiveRecord::Relation using hash. Perfect for APIs.

Overview

ActiveHashRelation is an innovative gem that offers a powerful alternative to the traditional ActiveRecord::Relation by enabling the execution of ActiveRecord queries using standard Hash structures. Initially developed to empower front-end teams to specify their data needs without constant backend assistance, this gem has evolved into a valuable tool for developers looking to simplify their API interactions. With its user-friendly interface, it allows for efficient filtering and querying of resources, making it a fantastic addition to any Ruby on Rails project.

This gem stands out by handling various types of filters and query aggregations, providing the flexibility to manipulate data directly through JSON. For anyone working on APIs, ActiveHashRelation is a game-changer that enhances performance and reduces the complexity of data retrieval.

Features

  • Flexible Querying: Allows you to filter resources based on associations and custom criteria, making data retrieval seamless and adaptable to your needs.
  • Aggregation Support: Facilitates aggregation queries such as sum, average, min, and max on any specified column, streamlining calculations without extra programming.
  • Security Options: Offers whitelist functionality for parameters, ensuring that only allowable attributes are accessed, minimizing potential security risks.
  • Simple Installation: Quick to set up by adding a single line to your Gemfile, making it accessible even for those new to Ruby on Rails.
  • Custom Filter Application: Exposes a straightforward method, apply_filters, which allows developers to incorporate custom filters before executing queries.
  • ActiveRecord Integration: Built to work seamlessly with ActiveRecord, allowing you to leverage existing models and structures while enhancing query capabilities.
  • Comprehensive Data Type Support: Supports various column types including Integer, Float, Decimal, Date, and more, providing a versatile filtering experience.
  • Ease of Use: The one-method design ensures that setting up complex filters is straightforward, minimizing boilerplate code and enhancing readability.
rails
Ruby on Rails

Ruby on Rails, often referred to as Rails, is an open-source web application framework written in Ruby. Known for its convention over configuration and don't repeat yourself (DRY) principles, Rails simplifies and accelerates the development of database-backed web applications.