Used index_by(&:id)
instead of map { |u| [u.id, u] }.to_h
thanks to @cvx’s recommendation.
Also renamed the moderators
variable to not clash with method of the same name.
Used index_by(&:id)
instead of map { |u| [u.id, u] }.to_h
thanks to @cvx’s recommendation.
Also renamed the moderators
variable to not clash with method of the same name.
How about more code golf?
CategoryMods.new(row.category_id, mods.values_at(row.user_ids))
Hm, that didn’t work as expected
My bad, values_at
accepts varargs, not an array:
CategoryMods.new(row.category_id, mods.values_at(*row.user_ids))