{"id":16805499,"url":"https://github.com/dewski/active_denormalize","last_synced_at":"2026-04-18T14:04:44.652Z","repository":{"id":195376949,"uuid":"692809226","full_name":"dewski/active_denormalize","owner":"dewski","description":"ActiveDenormalize is a gem that allows you to denormalize data across your ActiveRecord models.","archived":false,"fork":false,"pushed_at":"2023-09-17T17:39:09.000Z","size":22211,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-03T19:40:44.043Z","etag":null,"topics":["denormalization","gem","rails"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/active_denormalize","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dewski.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-09-17T16:42:20.000Z","updated_at":"2023-09-17T17:38:39.000Z","dependencies_parsed_at":"2023-09-17T18:09:29.254Z","dependency_job_id":null,"html_url":"https://github.com/dewski/active_denormalize","commit_stats":null,"previous_names":["dewski/active_denormalize"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dewski/active_denormalize","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dewski%2Factive_denormalize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dewski%2Factive_denormalize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dewski%2Factive_denormalize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dewski%2Factive_denormalize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dewski","download_url":"https://codeload.github.com/dewski/active_denormalize/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dewski%2Factive_denormalize/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31971500,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["denormalization","gem","rails"],"created_at":"2024-10-13T09:48:26.468Z","updated_at":"2026-04-18T14:04:44.623Z","avatar_url":"https://github.com/dewski.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ActiveDenormalize\n\nActiveDenormalize is a gem that allows you to denormalize data across your ActiveRecord models. It currently supports `belongs_to` relationships.\n\nBelow is a simple example which you can use to get started (and mostly until further documentation is added in this README).\n\n```ruby\nclass Product \u003c ApplicationRecord\n  has_many :inventory_checks\nend\n\nclass InventoryCheck \u003c ApplicationRecord\n  belongs_to :product, denormalize: true\nend\n```\n\nActiveDenormalize works by adding create, update, and destroy `after_*_commit` callbacks to the host model, in this case InventoryCheck, which will update the denormalized attributes on the Product model.\n\nTo know which attributes to denormalize on to the Product model, ActiveDenormalize will look for `inventory_check` prefixed columns on the Product model. For example, if you have a `inventory_check_id` column on the Product model, ActiveDenormalize will update that column with the ID of most recent InventoryCheck record that belong to the Product.\n\n```ruby\n# No InventoryCheck has been created yet\n\u003e product = Product.create(name: \"Product 1\")\n\u003e product.inventory_check_id\n=\u003e nil\n\u003e product.inventory_check_created_at\n=\u003e nil\n\u003e product.inventory_check_status\n=\u003e nil\n\u003e product.inventory_check_denormalized_at\n=\u003e nil\n\n# Updates the Product record to know about the newest InventoryCheck\n\u003e first_inventory_check = InventoryCheck.create(product: product, status: \"backordered\")\n\u003e first_inventory_check.id\n=\u003e 1\n\u003e product.reload.inventory_check_id\n=\u003e 1\n\u003e product.inventory_check_created_at\n=\u003e Sun, 17 Sep 2023 17:28:13.674818427 UTC +00:00\n\u003e product.inventory_check_status\n=\u003e \"backordered\"\n\u003e product.inventory_check_denormalized_at\n=\u003e Sun, 17 Sep 2023 17:28:13.674818427 UTC +00:00\n\n# Updates the Product record to know about the newest InventoryCheck\n\u003e second_inventory_check = InventoryCheck.create(product: product, status: \"available\")\n\u003e second_inventory_check.id\n=\u003e 2\n\u003e product.reload.inventory_check_id\n=\u003e 2\n\u003e product.inventory_check_created_at\n=\u003e Sun, 17 Sep 2023 17:28:53.903842001 UTC +00:00\n\u003e product.inventory_check_status\n=\u003e \"available\"\n\u003e product.inventory_check_denormalized_at\n=\u003e Sun, 17 Sep 2023 17:28:53.903842001 UTC +00:00\n\u003e second_inventory_check.destroy\n\n# Reverts to the previous InventoryCheck record\n\u003e product.reload.inventory_check_id\n=\u003e 1\n\u003e product.inventory_check_created_at\n=\u003e Sun, 17 Sep 2023 17:28:13.674818427 UTC +00:00\n\u003e product.inventory_check_status\n=\u003e \"backordered\"\n\u003e product.inventory_check_denormalized_at\n=\u003e Sun, 17 Sep 2023 17:28:13.674818427 UTC +00:00\n\n# Updates the denormalized representation of the InventoryCheck on Product\n\u003e first_inventory_check.update!(status: \"available\")\n\u003e product.reload.inventory_check_id\n=\u003e 1\n\u003e product.inventory_check_created_at\n=\u003e Sun, 17 Sep 2023 17:28:13.674818427 UTC +00:00\n\u003e product.inventory_check_status\n=\u003e \"available\"\n\u003e product.inventory_check_denormalized_at # This timestamp will be updated\n=\u003e Sun, 17 Sep 2023 17:31:16.388224345 UTC +00:00\n```\n\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"active_denormalize\"\n```\n\nAnd then execute:\n\n```bash\n$ bundle\n```\n\nOr install it yourself as:\n\n```bash\n$ gem install active_denormalize\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/active_denormalize. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/active_denormalize/blob/main/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdewski%2Factive_denormalize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdewski%2Factive_denormalize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdewski%2Factive_denormalize/lists"}