Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

提出物詳細画面で余分なクエリを削除しました #4175

Merged
merged 2 commits into from
Feb 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions app/controllers/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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!
Expand Down