Skip to content

Instantly share code, notes, and snippets.

@spk
Last active December 15, 2015 10: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 spk/5245216 to your computer and use it in GitHub Desktop.
Save spk/5245216 to your computer and use it in GitHub Desktop.
Regenerate all ES indexes
# encoding: UTF-8
namespace :indexes do
desc "Regenerate all ES indexes"
task :regenerate => [:environment] do
Rails.application.eager_load!
ActiveRecord::Base.descendants.each do |model|
if model.respond_to?(:tire)
puts "* (Re)generating indexes for model #{model.name}"
sh "bundle exec rake environment tire:import CLASS='#{model.name}'"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment