For some very rich models I have I want to be able to check the RABL cache keys from the controller and only eager load related models when necessary. The following pseudo-code is the basic idea, and the problem is the fragment_exists? call. What can I use to see whether the RABL cached value is there?
ids = {}
models = Model.all.to_a
models.each_with_index do |m|
if !fragment_exists?(m)
ids[m.id] = i
end
end
Model.includes(:related1, :related2).where(id: ids.keys).each do |m|
models[ids[m.id]] = m
end unless ids.empty?
@models = models
render "models/index"
For some very rich models I have I want to be able to check the RABL cache keys from the controller and only eager load related models when necessary. The following pseudo-code is the basic idea, and the problem is the fragment_exists? call. What can I use to see whether the RABL cached value is there?