{"id":20054950,"url":"https://github.com/8parth/make_model_searchable","last_synced_at":"2025-05-05T13:31:57.100Z","repository":{"id":56882637,"uuid":"73839038","full_name":"8parth/make_model_searchable","owner":"8parth","description":"Adds simlpe search functionality to models","archived":false,"fork":false,"pushed_at":"2019-12-03T18:30:23.000Z","size":36,"stargazers_count":26,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-07-16T06:52:14.941Z","etag":null,"topics":["gem","make-model-searchable","rails-gem","ruby-gem"],"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/8parth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-15T17:37:09.000Z","updated_at":"2023-08-28T07:34:49.000Z","dependencies_parsed_at":"2022-08-20T13:00:45.730Z","dependency_job_id":null,"html_url":"https://github.com/8parth/make_model_searchable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/8parth%2Fmake_model_searchable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/8parth%2Fmake_model_searchable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/8parth%2Fmake_model_searchable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/8parth%2Fmake_model_searchable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/8parth","download_url":"https://codeload.github.com/8parth/make_model_searchable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224453018,"owners_count":17313668,"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":["gem","make-model-searchable","rails-gem","ruby-gem"],"created_at":"2024-11-13T12:44:55.226Z","updated_at":"2024-11-13T12:44:55.927Z","avatar_url":"https://github.com/8parth.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MakeModelSearchable \n[![Code Triagers Badge](https://www.codetriage.com/8parth/make_model_searchable/badges/users.svg)](https://www.codetriage.com/8parth/make_model_searchable)  [![Code Climate](https://codeclimate.com/github/8parth/make_model_searchable/badges/gpa.svg)](https://codeclimate.com/github/8parth/make_model_searchable)   [![Gem Version](https://badge.fury.io/rb/make_model_searchable.svg)](https://badge.fury.io/rb/make_model_searchable)\n\nModuler solution to add search functionality for selected fields.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'make_model_searchable'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install make_model_searchable\n\n## Usage\n\n###### To add search functionality to a model, for example User add following line to your model.\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  searchable_attributes :first_name, :last_name\nend\n```\nThen use \n```ruby\ndef index\n  User.search(\"something\")\nend\n```\n\nsearchable_attributes line makes model searchable by adding search method to User model. \nSpecifying attributes by :first_name, :last_name enables searching in specied fields. It is optional to specify attributes, if no attributes are specified then all attributes are searched.\n\n\n###### To enable searching from associations, you can mention asssociation name with attributes to be searched from that association as below: \n\nSuppose our user has many posts, then in our model\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  has_many :posts\n  searchable_attributes :name, posts: [:title]\nend\n```\n\nor if you want to search from all text or string fields,\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  has_many :posts\n  searchable_attributes :name, posts: []\nend\n```\n\n\nThen use,\n```ruby\ndef index\n  User.search(\"something\")\nend\n```\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/8parth/make_model_searchable. 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\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F8parth%2Fmake_model_searchable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F8parth%2Fmake_model_searchable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F8parth%2Fmake_model_searchable/lists"}