Sha256: 7a5c13ffff19c917c17bf9124646df48a5255396ed4195a8e5e2a00495ce6c57

Contents?: true

Size: 677 Bytes

Versions: 8

Compression:

Stored size: 677 Bytes

Contents

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

8 entries across 8 versions & 2 rubygems

Version Path
searchkick-3.1.2 lib/searchkick/tasks.rb
searchkick-3.1.1 lib/searchkick/tasks.rb
searchkick-3.1.0 lib/searchkick/tasks.rb
searchkick-3.0.3 lib/searchkick/tasks.rb
searchkick_evichat-0.0.2 lib/searchkick/tasks.rb
searchkick-3.0.2 lib/searchkick/tasks.rb
searchkick-3.0.1 lib/searchkick/tasks.rb
searchkick-3.0.0 lib/searchkick/tasks.rb