From b542f8072d206a55a4cf24b74b4e5e83987fc967 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Sat, 26 Apr 2014 10:58:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=AB=9E=E8=B5=9B=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E9=A1=B5=E9=9D=A2=E4=B8=AD=E7=9A=84=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/contests_controller.rb | 22 +++++++++++----------- app/helpers/contests_helper.rb | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 0f16a81c..14395ac0 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -33,15 +33,6 @@ class ContestsController < ApplicationController if params[:contest_sort_type].present? case params[:contest_sort_type] when '0' - unless @offset == 0 - @contests = @contests.offset(@offset).limit(@limit).all.reverse - else - limit = @contest_count % @limit - limit = @limit if limit == 0 - @contests = @contests.offset(@offset).limit(limit).all.reverse - end - @s_state = 0 - when '1' unless @offset == 0 @contests = @contests.reorder('contests.commit').offset(@offset).limit(@limit).all.reverse else @@ -49,6 +40,15 @@ class ContestsController < ApplicationController limit = @limit if limit == 0 @contests = @contests.reorder('contests.commit').offset(@offset).limit(limit).all.reverse end + @s_state = 0 + when '1' + unless @offset == 0 + @contests = @contests.reorder('contests.created_on').offset(@offset).limit(@limit).all.reverse + else + limit = @contest_count % @limit + limit = @limit if limit == 0 + @contests = @contests.reorder('contests.created_on').offset(@offset).limit(limit).all.reverse + end @s_state = 1 when '2' unless @offset == 0 @@ -62,11 +62,11 @@ class ContestsController < ApplicationController end else unless @offset == 0 - @contests = @contests.reorder('contests.commit').offset(@offset).limit(@limit).all.reverse + @contests = @contests.reorder('contests.created_on').offset(@offset).limit(@limit).all.reverse else limit = @contest_count % @limit limit = @limit if limit == 0 - @contests = @contests.reorder('contests.commit').offset(@offset).limit(limit).all.reverse + @contests = @contests.reorder('contests.created_on').offset(@offset).limit(limit).all.reverse end @s_state = 1 end diff --git a/app/helpers/contests_helper.rb b/app/helpers/contests_helper.rb index cb4d6a0f..36f2351c 100644 --- a/app/helpers/contests_helper.rb +++ b/app/helpers/contests_helper.rb @@ -62,12 +62,12 @@ module ContestsHelper content = ''.html_safe case state when 0 - content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'contests', action: 'index' ,:contest_sort_type => '1'})) - content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'contests', action: 'index' ,:contest_sort_type => '0'}, :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'contests', action: 'index' ,:contest_sort_type => '1'})) + content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'contests', action: 'index' ,:contest_sort_type => '0'}, :class=>"selected"), :class=>"selected") when 1 - content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'contests', action: 'index' ,:contest_sort_type => '1'}, :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'contests', action: 'index' ,:contest_sort_type => '0'})) + content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'contests', action: 'index' ,:contest_sort_type => '1'}, :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'contests', action: 'index' ,:contest_sort_type => '0'})) end content = content_tag('ul', content) content_tag('div', content, :class => "tabs")