{"id":29058710,"url":"https://github.com/foca/granola-rails","last_synced_at":"2026-05-19T09:08:25.049Z","repository":{"id":56875107,"uuid":"73729465","full_name":"foca/granola-rails","owner":"foca","description":"Rails wrapper for Granola","archived":false,"fork":false,"pushed_at":"2018-10-10T18:57:49.000Z","size":25,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-25T21:45:42.481Z","etag":null,"topics":["granola","json-serialization","lesscode","rails","ruby"],"latest_commit_sha":null,"homepage":"https://github.com/foca/granola","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/foca.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-14T17:23:37.000Z","updated_at":"2018-10-10T18:56:45.000Z","dependencies_parsed_at":"2022-08-20T10:11:07.486Z","dependency_job_id":null,"html_url":"https://github.com/foca/granola-rails","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/foca/granola-rails","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fgranola-rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fgranola-rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fgranola-rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fgranola-rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foca","download_url":"https://codeload.github.com/foca/granola-rails/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fgranola-rails/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265898352,"owners_count":23845777,"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":["granola","json-serialization","lesscode","rails","ruby"],"created_at":"2025-06-27T07:01:43.738Z","updated_at":"2026-05-19T09:08:20.007Z","avatar_url":"https://github.com/foca.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Granola::Rails [![Build Status](https://img.shields.io/travis/foca/granola-rails.svg)](https://travis-ci.org/foca/granola-rails) [![RubyGem](https://img.shields.io/gem/v/granola-rails.svg)](https://rubygems.org/gems/granola-rails)\n\nIntegrate [Granola](https://github.com/foca/granola) into Rails' rendering.\n\n## Usage\n\nOnce you install it, you can just use `render` to use Granola serializers:\n\n``` ruby\nclass UsersController \u003c ApplicationController\n  def show\n    user = User.find(params[:id])\n    render json: user\n  end\nend\n```\n\nThis would infer a `UserSerializer` (in `app/serializers/user_serializer.rb`).\nYou can pass any options to this method that you could pass to\n[`Granola::Rack#granola`][granola-rack]. For example, to use a different\nserializer:\n\n``` ruby\nclass UsersController \u003c ApplicationController\n  def show\n    user = User.find(params[:id])\n    render json: user, with: DetailedUserSerializer\n  end\nend\n```\n\n[granola-rack]: https://github.com/foca/granola/blob/master/lib/granola/rack.rb\n\n### Serialization formats\n\nAny serialization format you add to Granola via `Granola.render` will be\navailable to render through rails. For example:\n\n``` ruby\n# config/initializers/granola.rb\nGranola.render :yaml, via: YAML.method(:dump), content_type: Mime[:yaml].to_s\n\n# app/controllers/users_controller.rb\nclass UsersController \u003c ApplicationController\n  def show\n    user = User.find(params[:id])\n\n    respond_to do |format|\n      format.json { render json: user }\n      format.yaml { render yaml: user }\n    end\n  end\nend\n```\n\n## Rails Generators\n\nThis library provides a `serializer` generator:\n\n``` bash\n$ rails generate serializer user\n      create  app/serializers/user_serializer.rb\n      invoke  test_unit\n      create    test/serializers/user_serializer_test.rb\n```\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n``` ruby\ngem 'granola-rails'\n```\n\nAnd then execute:\n\n``` sh\n$ bundle\n```\n\nOr install it yourself as:\n\n``` sh\n$ gem install granola-rails\n```\n\n## License\n\nThe gem is available as open source under the terms of the MIT License. See the\n[LICENSE](./LICENSE) for detjsonails.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoca%2Fgranola-rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoca%2Fgranola-rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoca%2Fgranola-rails/lists"}