达到如下效果
pool = [] ModelName.all.each_with_index do |obj , index| pool.push [] if index % num == 0 pool.last.push obj end pool
(1..10).each_slice(3).to_a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]
#1 楼 @lolychee 3x~