{"id":18368771,"url":"https://github.com/greena13/snake-eyes","last_synced_at":"2026-04-16T03:32:47.758Z","repository":{"id":56896310,"uuid":"48980959","full_name":"greena13/snake-eyes","owner":"greena13","description":"Automatically convert params in your controllers from camel case to snake case","archived":false,"fork":false,"pushed_at":"2019-04-14T13:05:20.000Z","size":65,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-05T01:53:13.916Z","etag":null,"topics":["conversion","json","rails"],"latest_commit_sha":null,"homepage":null,"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/greena13.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-01-04T07:17:31.000Z","updated_at":"2019-04-14T13:05:22.000Z","dependencies_parsed_at":"2022-08-21T01:50:39.960Z","dependency_job_id":null,"html_url":"https://github.com/greena13/snake-eyes","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/greena13/snake-eyes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greena13%2Fsnake-eyes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greena13%2Fsnake-eyes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greena13%2Fsnake-eyes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greena13%2Fsnake-eyes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/greena13","download_url":"https://codeload.github.com/greena13/snake-eyes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greena13%2Fsnake-eyes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31870508,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"online","status_checked_at":"2026-04-16T02:00:06.042Z","response_time":69,"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":["conversion","json","rails"],"created_at":"2024-11-05T23:27:23.112Z","updated_at":"2026-04-16T03:32:47.722Z","avatar_url":"https://github.com/greena13.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://svgshare.com/i/CS9.svg\" width=\"200px\" /\u003e\u003cbr/\u003e\n  \u003ch2 align=\"center\"\u003eSnakeEyes\u003c/h2\u003e\n\u003c/p\u003e\n\n[![Gem](https://img.shields.io/gem/dt/snake-eyes.svg)]()\n[![Build Status](https://travis-ci.org/greena13/snake-eyes.svg)](https://travis-ci.org/greena13/snake-eyes)\n[![GitHub license](https://img.shields.io/github/license/greena13/snake-eyes.svg)](https://github.com/greena13/snake-eyes/blob/master/LICENSE)\n\nAutomatically convert between camel case APIs to snake case for your Rails code\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'snake-eyes'\n\nAnd then execute:\n\n    $ bundle\n\n## Usage\n\nTo use SnakeEyes, simply add the following to the top of any controller in which you wish to have snake case parameters. All controllers that inherit from it shall also have the behaviour\n\n```ruby\nclass JsonController \u003c ApplicationController\n  snake_eyes_params\n\n  def show\n    #reference the params method as normal\n  end\nend\n```\n\n### Dealing with nested params\n\nOnce `snake_eyes_params` has been enabled for a controller, `params` accepts an options hash, which can be used to specify which attributes should have the `_attributes` suffix appended.\n\n ```ruby\n class WithoutSnakeEyesController \u003c ApplicationController\n\n    def show\n       params # results in:\n       # {\n       #    'user' =\u003e {\n       #      'name' =\u003e 'John Smith',\n       #      'favouriteColor' =\u003e 'blue',\n       #      'address' =\u003e { line1: '123 street' },\n       #      'billingAddress' =\u003e { line1: '456 road' }\n       #    }\n       #}\n    end\n end\n\n class WithSnakeEyesController \u003c ApplicationController\n     snake_eyes_params\n\n     def show\n        params(nested_attributes: { user: [ :address, :billing_address ] }) # results in:\n        # {\n        #    'user_attributes' =\u003e {\n        #      'name' =\u003e 'John Smith',\n        #      'favourite_color' =\u003e 'blue',\n        #      'address_attributes' =\u003e { line1: '123 street' },\n        #      'billing_address_attributes' =\u003e { line1: '456 road' }\n        #    }\n        #}\n     end\n  end\n ```\n\n#### Avoid _attributes suffix on parents: the _ prefix\n\nTo specify nested objects that should not have the `_attributes` suffix (but contain attributes that should), you can prefix them with an underscore:\n\n\n```ruby\n class WithSnakeEyesController \u003c ApplicationController\n     snake_eyes_params\n\n     def show\n        params(nested_attributes: { _user: [ :address, :billing_address ] }) # results in:\n        # {\n        #    'user' =\u003e {\n        #      'name' =\u003e 'John Smith',\n        #      'favourite_color' =\u003e 'blue',\n        #      'address_attributes' =\u003e { 'line1: 123 street' },\n        #      'billing_address_attributes' =\u003e { line1: '456 road' }\n        #    }\n        #}\n     end\n  end\n ```\n\n#### Reference any element of an array: the '*' wildcard\n\nTo apply the `_attributes` suffix to all elements of an array, use the `'*'` wildcard in place of the array index:\n\n```ruby\nclass WithSnakeEyesController \u003c ApplicationController\n    snake_eyes_params\n\n    def show\n        # Given\n        params(nested_attributes: [ _array: { '*' =\u003e :string } ])\n\n        # If the params are:\n        #\n        # 'array' =\u003e [\n        #      { 'string' =\u003e 'string' },\n        #      { 'string' =\u003e 'string2' },\n        #  ]\n        #\n        # What will be returned:\n        #\n        # 'array' =\u003e [\n        #      { 'string_attributes' =\u003e 'string' },\n        #      { 'string_attributes' =\u003e 'string2' },\n        #  ]\n    end\nend\n```\n\n## Substitutions\n\nIf you want to substitute alternative values for the ones that the controller actually receives, you can do that using the `substitutions` option:\n\n```ruby\nclass WithSnakeEyesController \u003c ApplicationController\n    snake_eyes_params\n\n    def show\n        # Given\n        params(substitutions: {\n            shallow_object: {\n                price: { replace: 'FREE', with: 0.00 }\n            }\n        })\n\n        # If params is:\n        #\n        # 'shallowObject' =\u003e {\n        #      'price' =\u003e 'FREE'\n        #  }\n        #\n        # What will be returned:\n        #\n        # 'shallow_object' =\u003e {\n        #     'price' =\u003e 0.00\n        # }\n    end\nend\n```\n\nYou can also provide multiple substitutions as an array. They are matched left-to-right, and the first matching substitution is the one that is used.\n\n```ruby\nclass WithSnakeEyesController \u003c ApplicationController\n    snake_eyes_params\n\n    def show\n        # Given\n        params(substitutions: {\n            shallow_object: {\n                price: [\n                    { replace: 'FREE', with: 0.00 } ,\n                    { replace: 'EXPENSIVE', with: 999.00 }\n                ]\n            }\n        })\n\n        # If params is:\n        #\n        # 'shallowObject' =\u003e {\n        #      'price' =\u003e 'FREE'\n        #  }\n        #\n        # What will be returned:\n        #\n        # 'shallow_object' =\u003e {\n        #     'price' =\u003e 0.00\n        # }\n\n        # If params is:\n        #\n        # 'shallowObject' =\u003e {\n        #      'price' =\u003e 'EXPENSIVE'\n        #  }\n        #\n        # What will be returned:\n        #\n        # 'shallow_object' =\u003e {\n        #     'price' =\u003e 999.00\n        # }\n    end\nend\n```\n\n## Configuration\n\nBy default SnakeEyes logs the snake case parameters to the Rails console. You can prevent this behaviour by configuring the gem:\n\n```ruby\nSnakeEyes.configuration do |config|\n  config.log_snake_eyes_parameters = false\nend\n```\n\n## Contributing\n\n1. Fork it ( https://github.com/greena13/snake-eyes/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreena13%2Fsnake-eyes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreena13%2Fsnake-eyes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreena13%2Fsnake-eyes/lists"}