instead of `select.to_a` I think we can use `pluck(:id)`. Could you try it?