diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index 5f2417c4381..575e10a760e 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -10,7 +10,11 @@ def index; end def show @product = find_product - @reports = @product.user.reports.limit(10).order(reported_on: :DESC) + @reports = @product.user + .reports + .limit(10) + .includes(:comments, :checks) + .order(reported_on: :DESC) @practice = find_practice @footprints = find_footprints footprint! @@ -85,13 +89,13 @@ def find_my_product end def find_footprints - find_product.footprints.with_avatar.order(created_at: :desc) + @product.footprints.with_avatar.order(created_at: :desc) end def footprint! - return unless find_product.user != current_user + return unless @product.user != current_user - find_product.footprints.create_or_find_by(user: current_user) + @product.footprints.create_or_find_by(user: current_user) end def check_permission!