Consider find_each for looping through Active Record associations - Andy Croll

The standard method for enumerating through groups of objects, both through arrays in Ruby and through Active Record models in Rails, is each.However, if you are looping over a large amount of data, perhaps all the records for a model in order to backfill data, you can encounter severe memory and speed issues, both with loading and processing large volumes of records.You should consider the functionality provided by Active Record’s Batches. We’ll demonstrate using find_each.
Consider find_each for looping through Active Record associations - Andy Croll #ruby #rubydeveloper #rubyonrails #active #record https://rubyonrails.ba/single/consider-find_each-for-looping-through-active-record-associations-andy-croll

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles