Sha256: a2f2b2f47cc9dad6422f1885985abbf7ebe31d6f24a67e43fe170c64456cac3a
Contents?: true
Size: 964 Bytes
Versions: 5
Compression:
Stored size: 964 Bytes
Contents
namespace :ferret do # Rebuild index task. Declare the indexes to be rebuilt with the INDEXES # environment variable: # # INDEXES="my_model shared" rake ferret:rebuild desc "Rebuild a Ferret index. Specify what model to rebuild with the INDEXES environment variable." task :rebuild => :environment do if ENV['INDEXES'] indexes = ENV['INDEXES'].split indexes.each do |index_name| start = 1.minute.ago ActsAsFerret::rebuild_index index_name idx = ActsAsFerret::get_index index_name # update records that have changed since the rebuild started idx.index_definition[:registered_models].each do |m| m.records_modified_since(start).each do |object| object.ferret_update end end end else puts "set the INDEXES environment variable to the index names you want to rebuild:\nINDEXES=\"my_index another_index\" rake ferret:rebuild" end end end
Version data entries
5 entries across 5 versions & 1 rubygems