Sha256: 29b6211b96e87b45e71a482e9a3dd608d0213599d0e4e9404a655c5359bf4c25

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

sunspot_mongoid 2
====

A Sunspot wrapper for Mongoid that just works.

Gemfile
----
    gem 'sunspot_mongoid2'
    bundle install

For Rails 3.x
----

### Configure your gem

Create `config/initializers/sunspot_mongoid.rb`:

    Sunspot.session = Sunspot::Rails.build_session
    ActionController::Base.module_eval { include(Sunspot::Rails::RequestLifecycle) }
    
Don't forget to restart your rack server (or pow.cx)

### as plugin (only if really needed):

add gems to Gemfile as following,

    gem 'sunspot_mongoid2'
    gem 'sunspot_rails'

and install `sunspot_mongoid` as rails plugin,

    rails plugin install https://github.com/hlegius/sunspot_mongoid2.git


A Simple Example
----

    class Post
      include Mongoid::Document
      include Sunspot::Mongoid2

      searchable do
        text :title
        integer :foo_totals, multiple: true
      end

      field :title
    end

    class SomeController < ActionController::Base
      def index
        search = Sunspot.search(Post) do
          fulltext params[:q]
        end
        
        @results = search.results
        @total_lines = search.total
      end
    end

    # http://yourapplication.dev/search?q=foobarbaz

Links
----

* [sunspot](http://github.com/outoftime/sunspot)
* [sunspot_rails](http://github.com/outoftime/sunspot/tree/master/sunspot_rails/)



Copyright (and left)
----

Copyright (c) 2010 jugyo. See LICENSE for details.

A lot of other contributions were made before I did.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sunspot_mongoid2-0.5.1.7 README.md