Browse the Ruby on Rails Community.

You are here: Browse Railsplugins Acts As Searchable

Acts As Searchable

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.login”], :include => [:comments, :user] end

belongs_to :user
has_many :comments
  1. within console Entry.search(‘Josh Clayton’) #=> [<entry>, <entry>] Entry.search(‘ruby‘) #=> [<entry>, <entry>, <entry>]

=======

Copyright© 2008 Josh Clayton, released under the MIT license

NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly