Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 80 lines (50 sloc) 2.354 kB
2236550 @parndt Updated instructions for rubygems installation
parndt authored
1 # Search plugin for [Refinery CMS](http://www.refinerycms.com)
45ec12c Added Readme
Amanda Nicholas authored
2
86e8f9f @joemsak Give credit to the gem and point people there for more info & help o…
joemsak authored
3 Powered by: [acts_as_indexed](http://github.com/dougal/acts_as_indexed) - Check his readme and documentation for more info on how it works.
4
a8e679d @parndt Converted to a Rails3/Refinery CMS engine.
parndt authored
5 ## Installation
45ec12c Added Readme
Amanda Nicholas authored
6
5aef6f9 @parndt Updated readme to have syntax highlighting and to recommend installin…
parndt authored
7 Simply use this by adding the following to your `Gemfile`:
45ec12c Added Readme
Amanda Nicholas authored
8
5aef6f9 @parndt Updated readme to have syntax highlighting and to recommend installin…
parndt authored
9 ```ruby
2236550 @parndt Updated instructions for rubygems installation
parndt authored
10 gem 'refinerycms-search', '~> 2.0.0'
5aef6f9 @parndt Updated readme to have syntax highlighting and to recommend installin…
parndt authored
11 ```
45ec12c Added Readme
Amanda Nicholas authored
12
b9a1ba7 @adamico Add more install infos to readme.md, fixes #23
adamico authored
13 Now, run ``bundle install``
14
15 Next, to install the search plugin run:
16
17 rails generate refinery:search
18
19 Run database migrations:
20
21 rake db:migrate
22
23 Finally seed your database and you're done.
24
25 rake db:seed
26
42f00c5 @ugisozols Update readme.
ugisozols authored
27 ## RE-SAVE all records that have not been indexed before.
45ec12c Added Readme
Amanda Nicholas authored
28
6ceb51a @ugisozols Fix typo in readme.
ugisozols authored
29 A sample search form can be found in [views/refinery/shared/_search.html.erb](http://github.com/resolve/refinerycms-search/blob/master/app/views/refinery/shared/_search.html.erb).
a8e679d @parndt Converted to a Rails3/Refinery CMS engine.
parndt authored
30 You can either use this partial directly, or copy the appropriate parts.
45ec12c Added Readme
Amanda Nicholas authored
31
a8e679d @parndt Converted to a Rails3/Refinery CMS engine.
parndt authored
32 ## Searching
45ec12c Added Readme
Amanda Nicholas authored
33
25a5024 @parndt Let's try a different approach which is far more likely to work :-)
parndt authored
34 The default installation will search in Pages.
5aef6f9 @parndt Updated readme to have syntax highlighting and to recommend installin…
parndt authored
35 If you wish to find results in other plugins you have created or installed, you can specify these in `config/application.rb` like so:
45ec12c Added Readme
Amanda Nicholas authored
36
5aef6f9 @parndt Updated readme to have syntax highlighting and to recommend installin…
parndt authored
37 ```ruby
38 config.to_prepare do
39 Refinery.searchable_models = [Refinery::Page]
40 end
41 ```
45ec12c Added Readme
Amanda Nicholas authored
42
43 Simply add any additional models you wish to search to this array. For example, if you have the [portfolio plugin](http://github.com/resolve/refinerycms-portfolio) installed:
44
5aef6f9 @parndt Updated readme to have syntax highlighting and to recommend installin…
parndt authored
45 ```ruby
46 config.to_prepare do
47 Refinery.searchable_models = [Refinery::Page, Refinery::PortfolioEntry]
48 end
49 ```
eed054b @joemsak These changes help it work in Rails3 RefineryCMS acceptably.
joemsak authored
50
14c27f3 @joemsak Helpful tips in the README
joemsak authored
51 The above line will add indexing to PortfolioEntry in the portfolio plugin, which does not come indexed.
52
a8e679d @parndt Converted to a Rails3/Refinery CMS engine.
parndt authored
53 Any model you wish to search will need to be indexed using acts as indexed. To add indexing, simple add:
45ec12c Added Readme
Amanda Nicholas authored
54
5aef6f9 @parndt Updated readme to have syntax highlighting and to recommend installin…
parndt authored
55 ```ruby
56 acts_as_indexed :fields => [:title, :body]
57 ```
45ec12c Added Readme
Amanda Nicholas authored
58
5aef6f9 @parndt Updated readme to have syntax highlighting and to recommend installin…
parndt authored
59 If your model doesn't use a `:title` attribute, remember to add an `alias_attribute`:
284cb30 @joemsak README updated with a couple of friendly reminders
joemsak authored
60
5aef6f9 @parndt Updated readme to have syntax highlighting and to recommend installin…
parndt authored
61 ```ruby
62 alias_attribute :title, :name #for example
63 ```
284cb30 @joemsak README updated with a couple of friendly reminders
joemsak authored
64
5aef6f9 @parndt Updated readme to have syntax highlighting and to recommend installin…
parndt authored
65 You can use any public method, as well. So if you have `:first_name` and `:last_name` but a method like `name` to join them, it can be indexed.
25a5024 @parndt Let's try a different approach which is far more likely to work :-)
parndt authored
66
5aef6f9 @parndt Updated readme to have syntax highlighting and to recommend installin…
parndt authored
67 ```ruby
68 acts_as_indexed :fields => [:name, :biography]
25a5024 @parndt Let's try a different approach which is far more likely to work :-)
parndt authored
69
5aef6f9 @parndt Updated readme to have syntax highlighting and to recommend installin…
parndt authored
70 #...
25a5024 @parndt Let's try a different approach which is far more likely to work :-)
parndt authored
71
5aef6f9 @parndt Updated readme to have syntax highlighting and to recommend installin…
parndt authored
72 def name
73 [first_name, last_name].reject(&:blank?).join(' ')
74 end
75 ```
14c27f3 @joemsak Helpful tips in the README
joemsak authored
76
a8e679d @parndt Converted to a Rails3/Refinery CMS engine.
parndt authored
77 You will need to replace the indexed fields with those appropriate for your model.
14c27f3 @joemsak Helpful tips in the README
joemsak authored
78
b9a1ba7 @adamico Add more install infos to readme.md, fixes #23
adamico authored
79 If you wish to override the url used in the search results just add a `url` method to your model and the result of this method will be used instead.
Something went wrong with that request. Please try again.