Remove intermediary arrays when creating hash maps from results (#9291)

This commit is contained in:
Eugen Rochko
2018-11-16 15:02:18 +01:00
parent 01a8ab921e
commit 6d4438a6ae
11 changed files with 20 additions and 20 deletions

View File

@ -113,7 +113,7 @@ class ApplicationController < ActionController::Base
klass.reload_stale_associations!(cached_keys_with_value.values) if klass.respond_to?(:reload_stale_associations!)
unless uncached_ids.empty?
uncached = klass.where(id: uncached_ids).with_includes.map { |item| [item.id, item] }.to_h
uncached = klass.where(id: uncached_ids).with_includes.each_with_object({}) { |item, h| h[item.id] = item }
uncached.each_value do |item|
Rails.cache.write(item, item)