Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Merge 2 0 stable #21

Merged
merged 6 commits into from

2 participants

@parndt
Owner

This replaces #20 as I've done the "hard work" of merge conflicts.

@parndt parndt referenced this pull request
Closed

2 0 stable merge #20

@ugisozols ugisozols merged commit c126193 into master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 12, 2012
  1. @ugisozols
  2. @ugisozols

    Add Guard support.

    ugisozols authored
    Conflicts:
    
    	Gemfile
  3. @ugisozols

    Update readme.

    ugisozols authored
  4. @ugisozols

    Fix typo in readme.

    ugisozols authored
Commits on Apr 16, 2012
  1. @parndt
  2. @parndt

    Merge branch '2-0-stable'

    parndt authored
    Conflicts:
    	Gemfile
    	readme.md
    	refinerycms-search.gemspec
This page is out of date. Refresh to see the latest.
Showing with 31 additions and 20 deletions.
  1. +31 −20 readme.md
View
51 readme.md
@@ -7,9 +7,11 @@ Powered by: [acts_as_indexed](http://github.com/dougal/acts_as_indexed) - Check
## Installation
-Simply use this by adding the following to your ``Gemfile``:
+Simply use this by adding the following to your `Gemfile`:
- gem 'refinerycms-search', '~> 2.0.0'
+```ruby
+gem 'refinerycms-search', '~> 2.0.0', :git => 'git://github.com/resolve/refinerycms-search.git', :branch => '2-0-stable'
+```
## RE-SAVE all records that have not been indexed before.
@@ -19,39 +21,48 @@ You can either use this partial directly, or copy the appropriate parts.
## Searching
The default installation will search in Pages.
-If you wish to find results in other plugins you have created or installed, you can specify these in ``config/application.rb`` like so:
+If you wish to find results in other plugins you have created or installed, you can specify these in `config/application.rb` like so:
- config.to_prepare do
- Refinery.searchable_models = [Refinery::Page]
- end
+```ruby
+config.to_prepare do
+ Refinery.searchable_models = [Refinery::Page]
+end
+```
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:
- config.to_prepare do
- Refinery.searchable_models = [Refinery::Page, Refinery::PortfolioEntry]
- end
+```ruby
+config.to_prepare do
+ Refinery.searchable_models = [Refinery::Page, Refinery::PortfolioEntry]
+end
+```
The above line will add indexing to PortfolioEntry in the portfolio plugin, which does not come indexed.
Any model you wish to search will need to be indexed using acts as indexed. To add indexing, simple add:
- acts_as_indexed :fields => [:title, :body]
+```ruby
+acts_as_indexed :fields => [:title, :body]
+```
-If your model doesn't use a ``:title`` attribute, remember to add an ``alias_attribute``:
+If your model doesn't use a `:title` attribute, remember to add an `alias_attribute`:
- alias_attribute :title, :name #for example
+```ruby
+alias_attribute :title, :name #for example
+```
-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.
+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.
- acts_as_indexed :fields => [:name, :biography]
+```ruby
+acts_as_indexed :fields => [:name, :biography]
- #...
+#...
- def name
- (first_name, last_name).compact.join(' ')
- end
+def name
+ [first_name, last_name].reject(&:blank?).join(' ')
+end
+```
You will need to replace the indexed fields with those appropriate for your model.
-
-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.
+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.