{"id":15857902,"url":"https://github.com/revskill10/as_json_with_includes","last_synced_at":"2026-05-11T02:02:35.960Z","repository":{"id":62553603,"uuid":"62943700","full_name":"revskill10/as_json_with_includes","owner":"revskill10","description":"Because we don't need ActiveModelSerializer!!!","archived":false,"fork":false,"pushed_at":"2016-07-09T12:37:38.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-03-15T10:11:44.529Z","etag":null,"topics":["json","rails","rubygems"],"latest_commit_sha":null,"homepage":"","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/revskill10.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-09T10:08:06.000Z","updated_at":"2018-07-04T18:49:30.000Z","dependencies_parsed_at":"2022-11-03T04:45:26.186Z","dependency_job_id":null,"html_url":"https://github.com/revskill10/as_json_with_includes","commit_stats":null,"previous_names":["checkraiser/as_json_with_includes"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revskill10%2Fas_json_with_includes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revskill10%2Fas_json_with_includes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revskill10%2Fas_json_with_includes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revskill10%2Fas_json_with_includes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/revskill10","download_url":"https://codeload.github.com/revskill10/as_json_with_includes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246704033,"owners_count":20820516,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["json","rails","rubygems"],"created_at":"2024-10-05T20:42:40.647Z","updated_at":"2026-05-07T17:41:03.477Z","avatar_url":"https://github.com/revskill10.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AsJsonWithIncludes\n\n[![Build Status](https://travis-ci.org/checkraiser/as_json_with_includes.svg?branch=master)](https://travis-ci.org/checkraiser/as_json_with_includes)\n\n## Problem:\n\n- We have complicated includes\n\n```ruby\nincludes = [:a, :b, :c, :d, {:e =\u003e {:f =\u003e [:g, :g]}}]\n```\n\n- We can use it like this:\n\n```ruby\nmodel = model_1.submodels.includes(includes)\n```\n\n- The data is now in rails and we have to convert the data to json but we cannot do `render :json =\u003e submodels, :include =\u003e includes`\nthis is because the \":include =\u003e\" attribute expects a different format:\n\n```ruby\n[:a, :b, :c, :d, {:e =\u003e {:include =\u003e {:f =\u003e {:include =\u003e [:g, :h]}}}}]\n```\n\nwhich we have to manually write.\n\n## Solution: \n\nThis gem takes active_record_includes of the form:\n\n```ruby\n[:a, :b, :c, :d, {:e =\u003e {:f =\u003e [:g, :h]}}]\n```\n\nand returns:\n\n```ruby\n[:a, :b, :c, :d, {:e =\u003e {:include =\u003e {:f =\u003e {:include =\u003e [:g, :h]}}}}]\n```\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'as_json_with_includes'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install as_json_with_includes\n\n## Usage\n\n```ruby\nincludes = [:a, :b, {c: :d}]\nmodel = Model.where(...).as_json_with_includes(includes: includes)\n```\n\n## Testing\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/as_json_with_includes. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frevskill10%2Fas_json_with_includes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frevskill10%2Fas_json_with_includes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frevskill10%2Fas_json_with_includes/lists"}