Sha256: bab87faec0f501eafc6c735fa004f573e48f849e2a5423b30bbe79b2031113f3

Contents?: true

Size: 695 Bytes

Versions: 45

Compression:

Stored size: 695 Bytes

Contents

require "rake"

namespace :searchkick do
  desc "reindex model"
  task reindex: :environment do
    if ENV["CLASS"]
      klass = ENV["CLASS"].constantize rescue nil
      if klass
        klass.reindex
      else
        abort "Could not find class: #{ENV['CLASS']}"
      end
    else
      abort "USAGE: rake searchkick:reindex CLASS=Product"
    end
  end

  if defined?(Rails)

    namespace :reindex do
      desc "reindex all models"
      task all: :environment do
        Rails.application.eager_load!
        Searchkick.models.each do |model|
          puts "Reindexing #{model.name}..."
          model.reindex
        end
        puts "Reindex complete"
      end
    end

  end
end

Version data entries

45 entries across 45 versions & 3 rubygems

Version Path
searchkick-1.1.0 lib/searchkick/tasks.rb
searchkick-1.0.3 lib/searchkick/tasks.rb
searchkick-1.0.2 lib/searchkick/tasks.rb
searchkick-1.0.1 lib/searchkick/tasks.rb
searchkick-1.0.0 lib/searchkick/tasks.rb