Skip to content

Instantly share code, notes, and snippets.

@devn
Forked from jcoyne/gist:3350207
Created August 14, 2012 15:49
Show Gist options
  • Save devn/3350429 to your computer and use it in GitHub Desktop.
Save devn/3350429 to your computer and use it in GitHub Desktop.
Indexing record
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