diff --git a/app/controllers/asks_controller.rb b/app/controllers/asks_controller.rb index 9124f70..4ffefae 100644 --- a/app/controllers/asks_controller.rb +++ b/app/controllers/asks_controller.rb @@ -6,7 +6,7 @@ class AsksController < ApplicationController def index @per_page = 10 - @asks = Ask.normal.includes(:user,:last_answer,:last_answer_user,:topics).desc(:id).paginate(:page => params[:page], :per_page => @per_page) + @asks = Ask.normal.recent.includes(:user,:last_answer,:last_answer_user,:topics).paginate(:page => params[:page], :per_page => @per_page) end def show diff --git a/app/models/ask.rb b/app/models/ask.rb index dbe06eb..3793bac 100644 --- a/app/models/ask.rb +++ b/app/models/ask.rb @@ -35,6 +35,7 @@ class Ask # 正常可显示的问题, 前台调用都带上这个过滤 scope :normal, where(:spams_count.lt => Setting.ask_spam_max) scope :last_actived, desc(:answered_at) + scope :recent, desc("$natural") before_save :fill_default_values def fill_default_values