Skip to content

Commit 8beb899

Browse files
committed
added PinnedLink#list_includes scope
1 parent a88cc5c commit 8beb899

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

app/controllers/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def pull_pinned_links_and_hot_questions
261261
end
262262

263263
# eager loading revived collections' used relation to prevent N+1 queries
264-
@pinned_links = @pinned_links.includes(post: [:community])
264+
@pinned_links = @pinned_links.list_includes
265265
@hot_questions = @hot_questions.list_includes
266266
end
267267

app/models/pinned_link.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ class PinnedLink < ApplicationRecord
22
include MaybeCommunityRelated
33
belongs_to :post, optional: true
44

5+
scope :list_includes, lambda {
6+
includes(:post, post: [:community])
7+
}
8+
59
validate :check_post_or_url
610

711
# Is the link time-constrained?

0 commit comments

Comments
 (0)