competition list add filter

dev_aliyun
p31729568 5 years ago
parent c081ebe0db
commit 0af95aa86f

@ -28,6 +28,8 @@ class CompetitionsController < ApplicationController
competitions = Competition.where('status = 1 or published_at is not null')
case params[:category]
when 'nearly_published' then
competitions = competitions.where('published_at is not null AND status = 0')
when 'progressing' then
competitions = competitions.where('end_time > NOW()')
when 'ended' then

@ -3,6 +3,8 @@
<div class="mt20 mb20 clearfix">
<%= link_to '全部', competitions_path(category: ''), remote: true,
class: "fl mr20 font-16 bestChoose shixun_repertoire #{params[:category].blank? ? 'active' : ''}" %>
<%= link_to '即将发布', competitions_path(category: 'nearly_published'), remote: true,
class: "fl mr20 font-16 bestChoose shixun_repertoire #{params[:category] == 'nearly_published' ? 'active' : ''}" %>
<%= link_to '进行中', competitions_path(category: 'progressing'), remote: true,
class: "fl mr20 font-16 bestChoose shixun_repertoire #{params[:category] == 'progressing' ? 'active' : ''}" %>
<%= link_to '往期比赛', competitions_path(category: 'ended'), remote: true,

Loading…
Cancel
Save