Find_in_batches "NO BLOCK GIVEN (YIELD)"

I have a method in which I take the model and result_size. The first thing I'm trying to do in this method is:

array = model.logs.find_in_batches(:batch_size => result_size)

But this does not work; instead, it returns "No Block Given (Exit)". I guess I'm just a stranger to blocks and crops. If anyone could help me understand / fix this problem, I would really appreciate it!

Thanks in advance!

+1
source share
1 answer

find_in_batches expects you to pass values ​​to a block like this:

model.logs.find_in_batches(:batch_size => result_size) do |models|
  models.each do |model|
    model.do_something
  end
end
+6
source

All Articles