extract id from array and input new array with pluck
My old code
p = Program.all
p_ids = []
p.each {|m| p_ids << m.id }Refactored code
p_ids = Program.all.pluck(:id)
p = Program.all
p_ids = []
p.each {|m| p_ids << m.id }p_ids = Program.all.pluck(:id)