Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Rails plugin to add extra searching functionality to models.
Ruby JavaScript
Branch: master
Failed to load latest commit information.
generators/searchify_javascript removing console.log statement
lib actually, as_json is what we want, but to_json need to be called on t…
spec actually, as_json is what we want, but to_json need to be called on t…
tasks initial import
LICENSE initial import
README filling readme
Rakefile initial import
TODO filling readme
init.rb adding require statement so it gets loaded properly as a rails plugin
install.rb initial import
uninstall.rb initial import



This is a Rails plugin which adds some search functionality to models. It also includes a javascript file and helper methods for building a dynamic search form.


If you are running edge rails you can install the plugin straight from the repository:

	script/plugin install git://

Otherwise you can install it with this command:

	git clone --depth=1 git:// vendor/plugins/searchify

To use the dynamic form you need to install a javascript file using this command:

	script/generate searchify_javascript


This plugin uses the "paginate" method to perform a search on the model, so you need to install the will_paginate plugin/gem.

Currently only MySQL is fully supported. It may work on other database engines, just not as well.


You can use the "searchify" method in your model class to enable it for searching. Pass the columns you want to search to this method.

	class Product < ActiveRecord::Base
	  searchify :name, :description, :price, :created_at, :discontinued

You can then use the "search" method to search all or some of these columns. Here are some examples. => 'Puzzle', :description => '%forest%') # use percent sign for partial search => 'blue puzzle') # searches for partial word "blue" and "puzzle" in all columns => '2008-01-01', :created_at_to => '2008-02-01') => '<', :price => '40') # changes the comparison operator => 5, :per_page => 20, :order => 'name') # pass other options besides conditions

The searchify also allows you to include associations in the search. For example:

	class Category < ActiveRecord::Base
	  has_many :products
		searchify :name, :products => [:name, :description]

To search the product columns you need to prefix them with "products_" like this: => 'Big Ben') # finds all categories with a product called Big Ben => 'puzzle') # product columns are included

The main benefit of this plugin is how easy it is to add a dynamic search. You can use the searchify_fields_for helper method to generate dynamic fields for searching. Like this:

	<% form_tag products_path, :method => 'get' do %>
	  <%= searchify_fields_for Product %>
	  <p><%= submit_tag 'Search', :name => nil, :onclick => 'return searchify_submit()' %></p>
	<% end %>

Make sure you have the prototype libraries included and it should allow you to dynamically add and remove fields. Pretty cool huh?


Copyright (c) 2008 Ryan Bates, released under the MIT license
Something went wrong with that request. Please try again.