Method: ModelModalHelper#fetch_related_model

Defined in:
app/helpers/model_modal_helper.rb


57
58
59
60
61
62
# File 'app/helpers/model_modal_helper.rb', line 57

def fetch_related_model(model, relation)
  # First get the relationship from cache
  related_id = model.send("#{relation}_id")
  key = "model_modal::#{relation}::#{related_id}"
  Rails.cache.fetch(key, expires_in: 6.hours) { model.send(relation) }
end