Let the following each:
user_ids = [] users.each { |user| user_ids << user.id }
It can be simplified to:
user_ids = users.map { |user| user.id }
or even:
user_ids = users.map(&:id)