-
Couldn't load subscription status.
- Fork 81
Home
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.
To install the gem simply add the following line to the Gemfile, and run bundle install
gem 'scoped_search'To use the auto completer javascript based ui you’ll need to include jquery-ui, there are several ways to include jquery-ui, for example, add to the Gemfile:
gem 'jquery-rails'
gem 'jquery-ui-rails'Add the following tag to your view:
<%= text_field_tag("search", value,
:class => 'autocomplete-input form-control',
:autocomplete => 'off',
:placeholder => 'Search ..',
:'data-url' => "#{path}/auto_complete_search")
%>And add this to your application.js:
//= require jquery-ui/completer// run the auto completer script on first focus
$(document).on('focus', "#search", function(e) {
if ($(".autocomplete-clear").length == 0) {
$('#search').scopedSearch();
}
});
In your application.css, require the corresponding CSS module:
*= require jquery-ui/completerNote: Older versions of jquery-ui used jquery.ui.completer syntax for the require
- wvanbergen’s blog posts
- a simple demo application of the scoped_search GUI
- Outdated using scoped search in Portuguese
- Very short usage introduction in Swedish
- RDoc
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 Development page for some pointers. You can contact wvanbergen or weshays by sending a github message.