ActiveRecord find_each combined with limit and order

后端 未结 13 2104
温柔的废话
温柔的废话 2020-12-02 11:41

I\'m trying to run a query of about 50,000 records using ActiveRecord\'s find_each method, but it seems to be ignoring my other parameters like so:



        
13条回答
  •  一向
    一向 (楼主)
    2020-12-02 12:25

    You can try ar-as-batches Gem.

    From their documentation you can do something like this

    Users.where(country_id: 44).order(:joined_at).offset(200).as_batches do |user|
      user.party_all_night!
    end
    

提交回复
热议问题