diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e73786f58ba..648c9b0912f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -339,8 +339,9 @@ class ApplicationController < ActionController::Base end def build_not_found_page(status=404, layout=false) - @top_viewed = Topic.top_viewed(10) - @recent = Topic.recent(10) + category_topic_ids = Category.pluck(:topic_id).compact + @top_viewed = Topic.where.not(id: category_topic_ids).top_viewed(10) + @recent = Topic.where.not(id: category_topic_ids).recent(10) @slug = params[:slug].class == String ? params[:slug] : '' @slug = (params[:id].class == String ? params[:id] : '') if @slug.blank? @slug.gsub!('-',' ')