0.0
No commit activity in last 3 years
No release in over 3 years
Poor man's search engine module for Rails3 (Arel)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 3.0.0, ~> 3.2
>= 3.0.0
 Project Readme

PoorManSearch Build Status Coverage Status

This module implement Poor Man's Search Engin to a active-record object.

Poor Man's Search Engin is a SQL anti pattern that using LIKE with wildcards search..

Installation

Add this line to your application's Gemfile:

gem 'poor_man_search'

And then execute:

$ bundle

Usage

Example

A master table : users

email name rank registered_at
taro@yamada.example.com 山田太郎 1 2013-12-31 23:21:11
hana@yamada.example.com 山田華 3 2014-2-28 3:15:00
chad@miller.example.com Chad Miller 1 2014-2-28 16:23:15

Configure like this.

class User < ActiveRecord::Base
  extend PoorManSearch::Searchable
  string_search :name, :email
  number_search :rank
  time_search :registered_at
end

Search!

User.search "yamada"
email name rank registered_at
taro@yamada.example.com 山田太郎 1 2013-12-31 23:21:11
hana@yamada.example.com 山田華 3 2014-2-28 3:15:00

User.search "yamada 太郎"
email name rank registered_at
taro@yamada.example.com 山田太郎 1 2013-12-31 23:21:11

User.search "1"
email name rank registered_at
taro@yamada.example.com 山田太郎 1 2013-12-31 23:21:11
chad@miller.example.com Chad Miller 1 2014-2-28 16:23:15

User.search "2/28"
email name rank registered_at
hana@yamada.example.com 山田華 3 2014-2-28 3:15:00
chad@miller.example.com Chad Miller 1 2014-2-28 16:23:15

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request