From 2d80a0cd9ea6e5b116d11811ad163b5c0edeeed6 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Thu, 31 Mar 2011 01:04:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=8F=E4=BE=BF=E7=9C=8B=E7=9C=8B=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=AE=89=E6=8F=92=E5=85=A5?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E5=80=92=E5=BA=8F=E6=8E=92=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/asks_controller.rb | 2 +- app/models/ask.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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