public
Description: Plugin adding simple searching to ActiveRecord models
Clone URL: git://github.com/joshuaclayton/acts_as_searchable.git
Search Repo:
100644 23 lines (15 sloc) 0.678 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
ActsAsSearchable
================
 
ActsAsSearchable provides a simple way to search upon a model. It uses named_scope if available; otherwise, it will accept a block or return find(:all) with applicable conditions applied
 
 
Example
=======
 
class Entry < ActiveRecord::Base
  acts_as_searchable :on => [:title, :body, "comments.body", "CONCAT(users.first_name, ' ', users.last_name)", "users.login"], :include => [:comments, :user]
  
  belongs_to :user
  has_many :comments
end
 
# within console
Entry.search('Josh Clayton') #=> [<Entry>, <Entry>]
Entry.search('%ruby%') #=> [<Entry>, <Entry>, <Entry>]
 
=======
 
Copyright (c) 2008 Josh Clayton, released under the MIT license