0

Using acts_as_taggable_on to find a models instances with certain tags is done by something like this:

Ninja.tagged_with(["invincibility,uber-strength", any: true)

However, what if I have 2million ninjas in my ninja directory and want to run a job on many of them.

I could find in batches but I don't quite understand how to do this with tags on a model. For example:

Ninja.all.find_in_batches(batch_size:1000) do |group|
  group.each do |ninja|
    ninja.battle!
  end
end

Is there a way to batch the tagged with query?

Aacini
  • 65,180
  • 12
  • 72
  • 108
Michael K Madison
  • 2,242
  • 3
  • 21
  • 35

1 Answers1

0

OK, so tagged_with seems to return an ActiveRecord Relation so I assume find_in_batches should work as desired appended tagged_with.

Michael K Madison
  • 2,242
  • 3
  • 21
  • 35