Created
August 14, 2012 15:15
-
-
Save jcoyne/3350207 to your computer and use it in GitHub Desktop.
Indexing record
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Document < ActiveRecord::Base | |
after_save :index_record | |
before_destroy :remove_from_index | |
private | |
def to_solr | |
#TODO - implement a hash serialization of this record | |
end | |
def index_record | |
SolrService.add(self.to_solr) | |
SolrService.commit | |
end | |
def remove_from_index | |
SolrService.delete_by_id(self.id) | |
SolrService.commit | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment