Plugins - with_search

StarAdd to favorites

WithSearch is a plugin used to add "itunes like" filter/search functionality.

It add two parameters :search_columns and :search_for to the :find and :calculate ActiveRecord methods

Install

 script/plugin install http://svn.redpill.se/rails_plugins/with_search

 class Contact < ActiveRecord::Base
   with_search
 end

You can also specify default parameters directly in your model: Any valid active record parameters will work

 class Contact < ActiveRecord::Base
  with_search :search_columns  => ["contacts.first_name","contacts.last_name","units.name"], :include => :unit
 end

Usage

To find all contacts with: (first_name or last_name or unit.name = bob) and (first_name or last_name or unit.name = dylan)

 Contact.find(:all,:search_for => "bob dylan")

Of course you can specify which columns to search to over ride the default parameters

 Contact.find(:all,:search_columns => [:email,:last_name], :search_for => "bob dylan")

Tips

Install the companion plugnin: paginate_with_search to easily create a search/filter action with pagination

 script/plugin install http://svn.redpill.se/rails_plugins/paginate_search

 class UsersController < ApplicationController
  def   index
   @pages, @users = paginate :users , :search_for  => params[:search_for], :order  => params[:order], :per_page  => ROWS_PER_PAGE
  end
 end

Documentation

http://rdoc.redpill.se/with_search/

Redpill Linpro

http://ruby.redpill.se/

http://svn.redpill.se/rails_plugins/with_search

Rails' (MIT)

  • Currently 0.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Model

Tags

Comments

Add a comment

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?