| 1 |
= acts_as_ferret |
|---|
| 2 |
|
|---|
| 3 |
This ActiveRecord mixin adds full text search capabilities to any Rails model. |
|---|
| 4 |
|
|---|
| 5 |
It is heavily based on the original acts_as_ferret plugin done by |
|---|
| 6 |
Kasper Weibel and a modified version done by Thomas Lockney, which |
|---|
| 7 |
both can be found on http://ferret.davebalmain.com/trac/wiki/FerretOnRails |
|---|
| 8 |
|
|---|
| 9 |
== Installation |
|---|
| 10 |
|
|---|
| 11 |
=== Installation inside your Rails project via script/plugin |
|---|
| 12 |
|
|---|
| 13 |
script/plugin install svn://projects.jkraemer.net/acts_as_ferret/trunk/plugin/acts_as_ferret |
|---|
| 14 |
|
|---|
| 15 |
Aaf is is also available via git from Rubyforge: |
|---|
| 16 |
git clone git://rubyforge.org/actsasferret.git |
|---|
| 17 |
|
|---|
| 18 |
=== System-wide installation with Rubygems |
|---|
| 19 |
|
|---|
| 20 |
<tt>sudo gem install acts_as_ferret</tt> |
|---|
| 21 |
|
|---|
| 22 |
To use acts_as_ferret in your project, add the following line to your |
|---|
| 23 |
project's config/environment.rb: |
|---|
| 24 |
|
|---|
| 25 |
<tt>require 'acts_as_ferret'</tt> |
|---|
| 26 |
|
|---|
| 27 |
Call the aaf_install script inside your project directory to install the sample |
|---|
| 28 |
config file and the drb server start/stop script. |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
== Usage |
|---|
| 32 |
|
|---|
| 33 |
include the following in your model class (specifiying the fields you want to get indexed): |
|---|
| 34 |
|
|---|
| 35 |
<tt>acts_as_ferret :fields => [ :title, :description ]</tt> |
|---|
| 36 |
|
|---|
| 37 |
now you can use ModelClass.find_by_contents(query) to find instances of your model |
|---|
| 38 |
whose indexed fields match a given query. All query terms are required by default, |
|---|
| 39 |
but explicit OR queries are possible. This differs from the ferret default, but |
|---|
| 40 |
imho is the more often needed/expected behaviour (more query terms result in |
|---|
| 41 |
less results). |
|---|
| 42 |
|
|---|
| 43 |
Please see ActsAsFerret::ActMethods#acts_as_ferret for more information. |
|---|
| 44 |
|
|---|
| 45 |
== License |
|---|
| 46 |
|
|---|
| 47 |
Released under the MIT license. |
|---|
| 48 |
|
|---|
| 49 |
== Authors |
|---|
| 50 |
|
|---|
| 51 |
* Kasper Weibel Nielsen-Refs (original author) |
|---|
| 52 |
* Jens Kraemer <jk@jkraemer.net> (current maintainer) |
|---|
| 53 |
|
|---|