Skip to content

kgalli/search_qd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Quick and dirty fulltext search for an ActiveRecord model.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages