Project

search_qd

0.0
No commit activity in last 3 years
No release in over 3 years
SearchQd provides a search method for string/text columns of an ActiveRecord model. The search itself is handled via simple SQL LIKE statements. That is why it is called quick and dirty.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

SearchQd

DESCRIPTION

SearchQd extends ActiveRecord and offers a method called search_qd for a simple full text search. Simple because the search functionality is executed as SQL LIKE statements for given (text) columns.

Quick start

gem install search_qd
  • Rails 3

Add the following line to your Gemfile

gem 'search_qd'
  • ActiveRecord outside of Rails
require 'search_qd'
ActiveRecord::Base.send(:include, SearchQd)

Usage

Assuming your model name is Blog and the model has two text columns title and content:

class Blog < ActiveRecord::Base
  search_qd_columns :title, :content
end
# search for 'some text to search for' in title and content column
Blog.search_qd("some text to seach for") 
# search for 'some text to search for' in title column
Blog.search_qd("some text to search for", ["title"]) 
# search for 'some text to search for' in user_name or title column 
Blog.search_qd("some text to search for", ["user_name", "title"]) 

As shown in the example above the search_qd method expects the search query as a string and a list of columns. If no list of columns is given, the search_qd method uses the column list defined by search_qd_columns (see class Blog definition).

REQUIREMENTS

  • ActiveRecord
  • Ruby 1.9.*

License

This gem is created by Karsten Gallinowski and released under the MIT License.