An AREL based search solution for Rails.
=
Add to Gemfile
gem 'winnow', git: '[email protected]:blake-education/winnow.git'
Define searchable names.
These are column names suffixed with a predicate. See Predicates for a [non-comprehensive] list
class SomeModel < ActiveRecord::Base
searchable :name_contains
end
def index
SomeModel.search(params[:search])
end
= form_for @search, url: some_models_path, html: { method: :get } do |f|
%label{ for: :name_contains } Name
= f.text_field :name_contains, size: 20
See https://github.com/rails/rails/blob/master/activerecord/lib/arel/predications.rb
=
This project rocks and uses MIT-LICENSE.