Skip to content

Instantly share code, notes, and snippets.

@jronallo

jronallo/gist:708769

Created Nov 21, 2010
Embed
What would you like to do?
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