{"id":16808907,"url":"https://github.com/timakin/autocompl","last_synced_at":"2025-03-22T02:31:46.136Z","repository":{"id":62553762,"uuid":"79995375","full_name":"timakin/autocompl","owner":"timakin","description":"A light-weight autocomplete integration for Rails application.","archived":false,"fork":false,"pushed_at":"2017-01-26T23:50:15.000Z","size":53524,"stargazers_count":17,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-25T09:44:01.469Z","etag":null,"topics":[],"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/timakin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-25T08:17:04.000Z","updated_at":"2018-03-11T18:50:19.000Z","dependencies_parsed_at":"2022-11-03T04:45:29.286Z","dependency_job_id":null,"html_url":"https://github.com/timakin/autocompl","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timakin%2Fautocompl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timakin%2Fautocompl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timakin%2Fautocompl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timakin%2Fautocompl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timakin","download_url":"https://codeload.github.com/timakin/autocompl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244173554,"owners_count":20410300,"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":[],"created_at":"2024-10-13T10:00:18.238Z","updated_at":"2025-03-22T02:31:45.798Z","avatar_url":"https://github.com/timakin.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"Autocompl\n====\n\nAutocompl is the light-weight library that provides an autocomplete function to Rails app.\n\nThis gem depends on Vanilla JavaScript, not jquery.\n\nSee the repo of [autoComplete](https://github.com/Pixabay/JavaScript-autoComplete) to check the usage of javascript code.\n\n## Installation\n\nInclude the gem on your Gemfile\n\n```\ngem 'autocompl'\n```\n\nInstall it\n\n```\nbundle install\n```\n\n## Configuration\n\nAdd it to your app/assets/javascripts/application.js file\n\n```\n//= require autocompl\n```\n\nAnd, add it to your app/assets/stylesheets/application.css file\n\n```\n*= require autocompl\n```\n\n## Example\n\nAs an example, let's configure for embed an autocomplete to search `Product#name`.\n\nAt first, edit `routes.rb` to let your javascript to access to the database.\n\nFor an example, if you'd like to add an endpoint to `ProductsController`, write down this code.\n\n```\nresources :products do\n  get \"autocomplete_endpoint\", on: :collection\nend\n```\n\nAfter that, add this to `products_controller.rb`\n\n```\nclass ProductsController \u003c ApplicationController\n  ...\n  # This will define `autocomplete_endpoint` on ProductsController.\n  autocomplete product: :name\n  ...\nend\n```\n\nFinally, write the javascript code and HTML to generate an autocomplete form.\n\n```\n# products.js\n$(document).ready(function() {\n  new autoComplete({\n      selector: 'input[name=\"productSearch\"]',\n      source: function(term, response){\n          $.getJSON('/products/autocomplete_endpoint', { term: term }, function(data){\n            term = term.toLowerCase();\n            var matches = [];\n            for (i=0; i\u003cdata.length; i++)\n              if (~data[i].toLowerCase().indexOf(term)) matches.push(data[i]);\n            response(matches);\n          });\n      }\n  });\n});\n\n\n# views/products/index.html.erb\n...\n\u003cinput autofocus type=\"text\" name=\"productSearch\" placeholder=\"Input a name of a product...\"\u003e\n...\n```\n\nIn addition, if you'd search with product `maker` name, that was internationalized with `name_ja` and `name_en` columns,\n\nrewrite your `products_controller.rb` like this.\n\n```\nclass ProductsController \u003c ApplicationController\n  ...\n  autocomplete product: :name, maker: [:name_ja, :name_en]\n  ...\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimakin%2Fautocompl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimakin%2Fautocompl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimakin%2Fautocompl/lists"}