{"id":18401939,"url":"https://github.com/dhyegocalota/active_admin-cep_auto_complete","last_synced_at":"2026-05-10T03:03:13.966Z","repository":{"id":62552737,"uuid":"106436506","full_name":"dhyegocalota/active_admin-cep_auto_complete","owner":"dhyegocalota","description":"Auto complete your addresses fields with Brazilian CEP (zip code) with your ActiveAdmin. :earth_americas:","archived":false,"fork":false,"pushed_at":"2018-03-16T21:12:38.000Z","size":60,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-13T08:46:56.659Z","etag":null,"topics":["activeadmin","activeadmin-plugin","brazil","cep","rails","ruby"],"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/dhyegocalota.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-10T15:34:20.000Z","updated_at":"2025-04-07T04:18:12.000Z","dependencies_parsed_at":"2022-11-03T04:15:30.038Z","dependency_job_id":null,"html_url":"https://github.com/dhyegocalota/active_admin-cep_auto_complete","commit_stats":null,"previous_names":["dhyegofernando/active_admin-cep_auto_complete"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/dhyegocalota/active_admin-cep_auto_complete","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhyegocalota%2Factive_admin-cep_auto_complete","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhyegocalota%2Factive_admin-cep_auto_complete/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhyegocalota%2Factive_admin-cep_auto_complete/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhyegocalota%2Factive_admin-cep_auto_complete/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dhyegocalota","download_url":"https://codeload.github.com/dhyegocalota/active_admin-cep_auto_complete/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhyegocalota%2Factive_admin-cep_auto_complete/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266608969,"owners_count":23955545,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["activeadmin","activeadmin-plugin","brazil","cep","rails","ruby"],"created_at":"2024-11-06T02:40:33.145Z","updated_at":"2026-02-28T12:14:56.439Z","avatar_url":"https://github.com/dhyegocalota.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ActiveAdmin CEP Auto Complete (brazilian postal code)\nAuto complete your addresses fields with Brazilian CEP (zip code).\n\n## Installation\nInclude to your Gemfile\n```ruby\ngem 'active_admin-cep_auto_complete'\n```\n\n\u003cimg src=\"./demo.gif\"/\u003e\n\n## Usage\n**1. Create a custom page in `app/admin/cep.rb`**\n```ruby\nActiveAdmin.register_page 'CEP' do\n  setup_cep_auto_complete\nend\n```\n\n**2. Add a CEP Input**\n```ruby\nf.input :cep, as: :cep\nf.input :street\nf.input :state\nf.input :city\nf.input :neighborhood\n```\n\n*p.s. if you have a different input name, you'll have to change your [URL option](https://github.com/dhyegofernando/active_admin-cep_auto_complete#options).*\n\n**3. It works!!**\n\n## Options\n\n**Input options**\n\nOption        | Type         | Default                                            | Description\n---           | ---          | ---                                                | ---\n`url`         | *string*     | Singular name of the input. e.g. `/cep`            | The route URL that CEP will be fetched from.\n`fields`      | *array*      | `[:street, :state, :city, :neighborhood]`          | The inputs names which will be auto completed.\n\n## Custom fields\n\nIf you want to add any custom field to be autocompleted, just do the follow:\n\n**1. Add to the CEP input options**\n```ruby\nf.input :cep, as: :cep, fields: [:state_id]\nf.input :state_id\n```\n\n**2. Add the render method to the controller**\n```ruby\nActiveAdmin.register_page 'CEP' do\n  setup_cep_auto_complete do\n    # New field\n    field :state_id do |cep|\n      state = State.where(\"title LIKE '%?%'\", cep.state).take\n      \n      if state.any?\n        state.id\n      end\n    end\n    \n    # Another new field that uses a result from other one\n    field :some_other_field do |cep|\n      \"State number #{cep.state_id}\"\n    end\n    \n    # Override an original field\n    field :street do |cep|\n      \"Street #{cep.street}\"\n    end\n  end\nend\n```\n\n**3. Now, the javascript will auto trigger the field with something like this:**\n```javascript\n$('#address_state_id').val(cep.state_id);\n```\n\n*p.s. it just a pseudo-code*\n\n**If you want support a different plugin (like [select2](https://github.com/select2/select2)) or any other javascript render method, you can do:**\n\n```javascript\n$('#address_state_id').on('active_admin:cep_auto_complete', function(e, value, cep, input) {\n  if (value) {\n    $(this).val(value);\n    $(this).trigger('change');\n  }\n});\n```\n\n## Maintainer\n[Dhyego Fernando](https://github.com/dhyegofernando)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhyegocalota%2Factive_admin-cep_auto_complete","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdhyegocalota%2Factive_admin-cep_auto_complete","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhyegocalota%2Factive_admin-cep_auto_complete/lists"}