Search code examples
ruby-on-railsruby-on-rails-plugins

Is it possible to get Rails' find_in_batches functionality in an older 2.2.2 project with a plugin?


Rails 2.2.2 didn't have find_in_batches functionality (or find_each).

Is there a plugin that provides this? I haven't been able to find one.


Solution

  • You can use paginated_each from will_paginate to achieve this. It can be used as a gem or a plugin.

    For example:

    MyClass.paginated_each(:per_page => 100) do |obj|
    
    end
    

    will load your objects in batches of 100.