pollyanna 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/README.rdoc +51 -7
  2. data/VERSION +1 -1
  3. data/pollyanna.gemspec +1 -1
  4. metadata +1 -1
@@ -1,12 +1,56 @@
1
- = Pollyanna - very simple search
1
+ = Pollyanna - very simple search for your ActiveRecord models
2
2
 
3
- == Make a model searchable
3
+ Pollyanna adds a very simple full text search to your ActiveRecord models.
4
+ Before saving, searchable models copy strings relevant to the search into a text column.
5
+ Pollyanna finds results for a query using LIKE patterns in SQL.
4
6
 
5
- - Add a text column "search_text" to a model
6
- - Have the model include Pollyanna::Searchable
7
- - Overwrite #search_text to define which text is indexed upon saving
8
- - Get a scope for your match with Model.search("query words here")
9
- - There's some more goodness I don't care to document. Use the code, Luke!
7
+ We found Pollyanna very useful for search-as-you-type boxes.
8
+
9
+ == Example
10
+
11
+ class Movie < ActiveRecord::Base
12
+ include Pollyanna::Searchable
13
+
14
+ def search_text
15
+ "#{title} #{year} #{director}"
16
+ end
17
+
18
+ end
19
+
20
+ class MoviesController
21
+
22
+ def index
23
+ @movies = Movie.search(params[:query])
24
+ end
25
+
26
+ end
27
+
28
+ == Making a model searchable
29
+
30
+ 1. Add a text column "search_text" to a model
31
+ 2. Have the model include <tt>Pollyanna::Searchable</tt>
32
+ 3. Overwrite <tt>search_text</tt> to define which text is indexed upon saving
33
+ 4. <tt>Model.search("query goes here")</tt> now gives you a scope for the results of your query. Blank queries return everything.
34
+
35
+ == Searching other columns
36
+
37
+ If you want to search a column other than <tt>search_text</tt>, you may say <tt>Movie.search(query, :by => "other_column")</tt>.
38
+
39
+ == How queries are matched
40
+
41
+ - Pollyanna matches partial words, so "oo" matches "foo".
42
+ - Multiple words in a query are AND-ed automatically.
43
+
44
+ == Installation
45
+
46
+ Add the following to your <tt>Initializer.run</tt> block in your <tt>environment.rb</tt>:
47
+ config.gem 'pollyanna', :source => 'http://gemcutter.org'
48
+ Then do a
49
+ sudo rake gems:install
50
+
51
+ Alternatively, use
52
+ sudo gem sources -a http://gemcutter.org
53
+ sudo gem install pollyanna
10
54
 
11
55
  == Credits
12
56
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.2
1
+ 1.0.3
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pollyanna}
8
- s.version = "1.0.2"
8
+ s.version = "1.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Henning Koch"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pollyanna
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch