From 5cbadfc591d2ce546fc83de9a52f77a63823cb91 Mon Sep 17 00:00:00 2001 From: hallelujah Date: Tue, 11 Feb 2014 11:50:24 +0200 Subject: [PATCH] Use Tire::Model::Import:Strategy in rake task This allows to import scoped documents in mongoid 3.x rake environment tire:import:model CLASS='Article.where(published: true)' Without it it will import all Article because of Mongoid::Criteria#tire is proxied to Article::tire --- lib/tire/tasks.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tire/tasks.rb b/lib/tire/tasks.rb index 3139f0cd..dd8d4b67 100644 --- a/lib/tire/tasks.rb +++ b/lib/tire/tasks.rb @@ -46,7 +46,7 @@ def import_model(index, klass, params) unless progress_bar(klass) puts "[IMPORT] Importing '#{klass.to_s}'" end - klass.tire.import(params) do |documents| + Tire::Model::Import::Strategy::from_class(klass, params).import do |documents| progress_bar(klass).inc documents.size if progress_bar(klass) documents end