Skip to content

Instantly share code, notes, and snippets.

@jronallo
Created November 21, 2010 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jronallo/708769 to your computer and use it in GitHub Desktop.
Save jronallo/708769 to your computer and use it in GitHub Desktop.
overriding Sunspot::Indexer.prepare to have different id field value
# in Rails place this in config/initializers/sunspot_indexer_prepare.rb
Sunspot::Indexer.module_eval do
alias :old_prepare :prepare
def prepare(model)
document = old_prepare(model)
document.fields_by_name(:id).first.value = document.fields_by_name(:filename).first.value
document
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment