diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 62b0a6329..64b16ae54 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -90,7 +90,7 @@ def set_list_posts SiteSetting['LotteryAgeDeprecationSpeed']] } sort_param = sort_params[params[:sort]&.to_sym] || { last_activity: :desc } @posts = @category.posts.undeleted.where(post_type_id: @category.display_post_types) - .includes(:post_type).list_includes.paginate(page: params[:page], per_page: 50) + .includes(:post_type, :tags).list_includes.paginate(page: params[:page], per_page: 50) .order(sort_param) end diff --git a/app/views/posts/_list.html.erb b/app/views/posts/_list.html.erb index 90066c51d..29a6b60cf 100644 --- a/app/views/posts/_list.html.erb +++ b/app/views/posts/_list.html.erb @@ -27,8 +27,8 @@
<% if is_question %> <% tag_set = post.tag_set %> - <% required_ids = post.category&.required_tag_ids %> - <% topic_ids = post.category&.topic_tag_ids %> + <% required_ids = defined?(@category) ? @category&.required_tag_ids : post.category&.required_tag_ids %> + <% topic_ids = defined?(@category) ? @category&.topic_tag_ids : post.category&.topic_tag_ids %> <% post.tags.category_sort_by(required_ids, topic_ids).each do |tag| %> <% required = required_ids&.include? tag.id %> <% topic = topic_ids&.include? tag.id %>