README.rdoc in sunspot_rails-0.10.9 vs README.rdoc in sunspot_rails-0.11.0

- old
+ new

@@ -6,56 +6,39 @@ * Configure Sunspot using config/sunspot.yml * Extend ActiveRecord for easy index configuration, search, and indexing * Automatically index ActiveRecord objects when they are saved, and remove them from the index when they are destroyed (can be disabled) -* Automatically commit Solr changes at the end of each request +* Automatically commit Solr changes at the end of each request (can be disabled) * Provide utility methods to find and fix orphaned documents and rebuild the Solr index for a given class * Provide rake tasks for starting and stopping the development Solr instance, using the configuration in sunspot.yml Sunspot::Rails has been tested with Rails versions 2.1, 2.2, and 2.3 == Installation -First, install the Sunspot and Sunspot::Rails gems: +For recent versions of Rails, In your project's <code>config/environment.rb</code>, add the following gem dependencies: - sudo gem install outoftime-sunspot outoftime-sunspot_rails --source=http://gems.github.com + config.gem 'sunspot', :lib => 'sunspot' + config.gem 'sunspot_rails', :lib => 'sunspot/rails' + +Install the gems with: -In your project's <code>config/environment.rb</code>, add the following gem dependencies: + rake gems:install - config.gem 'outoftime-sunspot', :lib => 'sunspot' - config.gem 'outoftime-sunspot_rails', :lib => 'sunspot/rails' +If you are using an older version of Rails that doesn't support plugins-as-gems, install the gems manually and install the plugin: -If you are using an older version of Rails that doesn't support plugins-as-gems, -use: - + sudo gem install sunspot sunspot_rails --source=http://gems.github.com + script/plugin install git://github.com/outoftime/sunspot_rails.git + +Generate the file <code>config/sunspot.yml</code>: -Create the file <code>config/sunspot.yml</code> and set it up for your environments. Here is a sample: + script/generate sunspot - common: &common - solr: - hostname: localhost - port: 8983 - - production: - <<: *common - solr: - path: /solr/myindex - - development: - <<: *common - solr: - port: 8982 - - test: - <<: *common - solr: - port: 8981 - Rails doesn't automatically load rake tasks from plugins installed as gems (https://rails.lighthouseapp.com/projects/8994/tickets/59). If you installed Sunspot::Rails as a gem, add the following line to your project's Rakefile: require 'sunspot/rails/tasks' @@ -218,10 +201,39 @@ the index but not the database, you can use the +index_orphans+ method; to remove those documents from the index, use +clean_index_orphans+. Note that neither of these operations should be needed if Sunspot and Sunspot::Rails are used as intended. + +== Testing Solr integration using RSpec + +To disable the sunspot-solr integration for your active record models, add the +following line to your spec_helper.rb + +require 'sunspot/spec/extension' + +This will disable all automatic after_save/after_destroy solr-requests generated +via the #searchable method. This will not disable/mock explicit calls in your code. + +If you want to test the sunspot-solr integration with active record, you can +reenable the after_save/after_destroy hooks by adding 'integrate_sunspot' in your +examples. + + describe Searches do + integrate_sunspot + + before(:each) do + @movie = Factory.create :movie + end + + it "should find a movie" do + Movie.search { keywords @movie.title }.first.should == @movie + end + end + + + == Further Reading Reading the {Sunspot documentation}[http://outoftime.github.com/sunspot/docs] is highly recommended. Sunspot::Rails exists to wrap Sunspot with a Rails-friendly API, but almost all of the functionality you use in Sunspot::Rails is @@ -238,9 +250,11 @@ - Mat Brown (mat@patch.com) - Peer Allan (peer.allan@gmail.com) - Michael Moen (michael@underpantsgnome.com) - Benjamin Krause (bk@benjaminkrause.com) +- Adam Salter (adam@codebright.net) +- Brandon Keepers (brandon@opensoul.org) == License Sunspot::Rails is distributed under the MIT License, copyright (c) 2009 Mat Brown