diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7ff472bf4..4b5c5f74b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -278,9 +278,8 @@ class ApplicationController < ActionController::Base end def render_not_found_page(status=404) - f = Topic.where(deleted_at: nil, archetype: "regular") - @latest = f.order('views desc').take(10) - @recent = f.order('created_at desc').take(10) + @top_viewed = TopicQuery.top_viewed(10) + @recent = TopicQuery.recent(10) @slug = params[:slug].class == String ? params[:slug] : '' @slug = (params[:id].class == String ? params[:id] : '') if @slug.blank? @slug.gsub!('-',' ') diff --git a/app/models/topic.rb b/app/models/topic.rb index 08161471f..f302e3079 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -96,7 +96,7 @@ class Topic < ActiveRecord::Base scope :created_since, lambda { |time_ago| where('created_at > ?', time_ago) } - scope :secured, lambda {|guardian| + scope :secured, lambda {|guardian=nil| ids = guardian.secure_category_ids if guardian # Query conditions diff --git a/app/views/exceptions/not_found.html.erb b/app/views/exceptions/not_found.html.erb index 5bf26a88b..f5852f326 100644 --- a/app/views/exceptions/not_found.html.erb +++ b/app/views/exceptions/not_found.html.erb @@ -4,8 +4,8 @@
- <%= t 'page_not_found.latest_topics' %>- <% @latest.each do |t| %> +<%= t 'page_not_found.popular_topics' %>+ <% @top_viewed.each do |t| %> <%= link_to t.title, t.relative_url %><% end %> @@ -17,7 +17,7 @@ <%= link_to t.title, t.relative_url %> <% end %> - <%= t 'page_not_found.see_more' %>… + <%= t 'page_not_found.see_more' %>… |