{"id":17680631,"url":"https://github.com/robacarp/barely_searchable","last_synced_at":"2025-03-30T19:12:30.035Z","repository":{"id":2440102,"uuid":"3410041","full_name":"robacarp/barely_searchable","owner":"robacarp","description":null,"archived":false,"fork":false,"pushed_at":"2012-09-25T23:10:59.000Z","size":100,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-01T23:07:03.434Z","etag":null,"topics":[],"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/robacarp.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":"2012-02-10T19:00:53.000Z","updated_at":"2015-11-10T23:50:45.000Z","dependencies_parsed_at":"2022-09-17T22:22:13.212Z","dependency_job_id":null,"html_url":"https://github.com/robacarp/barely_searchable","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robacarp%2Fbarely_searchable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robacarp%2Fbarely_searchable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robacarp%2Fbarely_searchable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robacarp%2Fbarely_searchable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robacarp","download_url":"https://codeload.github.com/robacarp/barely_searchable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246365645,"owners_count":20765546,"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-24T09:08:30.031Z","updated_at":"2025-03-30T19:12:30.012Z","avatar_url":"https://github.com/robacarp.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BarelySearchable\n\nThis is a bare-bones \"search\" function for your Rails 3 model layer.  Use with care, this is sequel trickery.\n\nIt adds `.search` to your models which builds out a simple `LIKE OR` type query to search your models and requires no external service (eg. sphinx) to index the your tables or any index tables.\n\nAs far as search engines go, this isn't very clever. It'll work for a handful of use cases, at least until you quit being lazy and install Sphinx.  :D\n\n## Installation\n\nAdd this line to your application's Gemfile: `gem 'barely_searchable'`\n\n## Quickstart\n\nIn your model:\n\n```\nclass User \u003c ActiveRecord::Base\n  #define the fields it'll search on\n  searches_on :id, :username, :email, :first_name, :last_name\nend\n\nclass Entry \u003c ActiveRecord::Base\n  searches_on :title, :body\nend\n```\n\nNow elsewhere in your application:\n\n```\n  def search_users\n    @users = User.search 'user@domain.com'\n  end\n  \n  def search_blogs\n    #Regular model querying methods still work just fine.\n    @entries = Entry.with_permissions_to(:show).search(\"friendship is unnecessary, like philosophy\").limit(15)\n  end\n```\n\n## More details\n\nIn your models, you can specify conditions on the search parameters to exclude them from searches.  This is useful for search query optimization or selective searches.\n\n```\nclass Order \u003c ActiveRecord::Base\n  #search these columns always\n  searches_on :user_id, :shipping_city\n\n  # Will only search these columns when the type-casted value isn't zero\n  searches_on :subtotal, :tax, :total, unless: Proc.new{|value| value == 0}\n\n  # Only search this column if the query is longer thahn 3 characters\n  searches_on :email, if: Proc.new{|value| value.length \u003e 3}\nend\n```\n\nSearch content is cast to the column data type before calling if/unless blocks.\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobacarp%2Fbarely_searchable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobacarp%2Fbarely_searchable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobacarp%2Fbarely_searchable/lists"}