Skip to content
Dominic Cleal edited this page Jan 19, 2017 · 34 revisions

scoped_search is a simple Rails plugin that will make it easy to search your ActiveRecord models. Searching is performed using a query string, which should be passed to the named_scope search_for that uses SQL LIKE conditions for searching (ILIKE for Postgres). You can specify what fields should be used for searching.

Topics

Installing scoped_search

To install the gem simply add the following line to the Gemfile, and run bundle install:

gem 'scoped_search'

Once installed, start adding scoped_search definitions to models that need it, and you can then call ExampleModel.search_for('name = foo'). See Usage for more examples.

To use the auto completer JavaScript-based UI, you will also need jquery-ui installed. More information on the Autocompletion wiki page.

Additional resources

Support for different databases

Because the library generates standard SQL, it should work for all databases that respect the SQL standard. However, there are small differences between the different databases that may warrant different handling.

Scoped search comes with adapters for SQLite, MySQL and PostgreSQL to ensure consistent results across databases. We will only accept support for open source databases to the gem. However, some plugins exists to improve scoped_search’s results for other databases as well.

- Oracle: https://github.com/wvanbergen/scoped_search-oracle_enhanced
- H2: https://github.com/wvanbergen/scoped_search-h2

Contributing

This plugin is released under the MIT license.

If you want to hack on this plugin or change it to suit your needs, see the CONTRIBUTING.rdoc for some pointers.