eager load attachments to avoid n+1

pull/7876/head
ulferts 5 years ago
parent 4bb8b9da13
commit 737fd6ec91
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 9
      modules/ifc_models/app/controllers/ifc_models/ifc_models_controller.rb

@ -34,17 +34,15 @@ module ::IFCModels
before_action :find_project_by_project_id, only: %i[index new create show show_defaults edit update destroy]
before_action :find_ifc_model_object, except: %i[index new create]
before_action :find_all_ifc_models, only: %i[show show_defaults]
before_action :find_all_ifc_models, only: %i[show show_defaults index]
before_action :authorize
menu_item :ifc_models
def index
@ifc_models = @project
.ifc_models
.order('created_at ASC')
.includes(:uploader, :project)
@ifc_models = @ifc_models
.includes(:project, :uploader)
end
def new
@ -116,6 +114,7 @@ module ::IFCModels
def find_all_ifc_models
@ifc_models = @project
.ifc_models
.includes(:attachments)
.order('created_at ASC')
end

Loading…
Cancel
Save