Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

blake-education/winnow

Repository files navigation

Build Status

Winnow

An AREL based search solution for Rails.

=

Usage

Gemfile

Add to Gemfile

gem 'winnow',            git: '[email protected]:blake-education/winnow.git'

Model

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

Controller

def index
  SomeModel.search(params[:search])
end

View

= form_for @search, url: some_models_path, html: { method: :get } do |f|
  %label{ for: :name_contains } Name
  = f.text_field :name_contains, size: 20

Predicates

See https://github.com/rails/rails/blob/master/activerecord/lib/arel/predications.rb

=

This project rocks and uses MIT-LICENSE.