From 7ec60e32bc67043ee555adc2636804feb7a83691 Mon Sep 17 00:00:00 2001 From: nccu Date: Fri, 9 Jan 2015 15:23:26 +0800 Subject: [PATCH] fix news count --- app/controllers/news_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index aaf4a8e..5d5193f 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -7,13 +7,13 @@ class NewsController < ApplicationController if params[:keywords] !params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:is_top=>"desc",:postdate=>"desc"} news = NewsBulletin.where(:title.ne => "").any_of(:title => /#{params[:keywords].to_s}/i).is_approved.order_by(sort).filter_by_categories(["all"]).per(15) if !params[:keywords].nil? - news_count = news.count + news_count = ",共有" + news.count.to_s + "筆資料" keyword = "搜尋標題有關 ' " + params[:keywords] + " '" elsif params[:department] !params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:is_top=>"desc",:postdate=>"desc"} dept = Department.find_by(:uid => params["department"].split("-").last) rescue nil news = NewsBulletin.where(:title.ne => "" ,:department => dept).is_approved.order_by(sort).filter_by_categories(["all"]) if !dept.nil? - news_count = news.count + news_count = ",共有" + news.count.to_s + "筆資料" keywords = params[:department].split("-") keywords.delete(keywords.last) @@ -27,7 +27,7 @@ class NewsController < ApplicationController unit = Unit.find_by(:uid => params["unit"].split("-").last) rescue nil !params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:is_top=>"desc",:postdate=>"desc"} news = NewsBulletin.where(:title.ne => "" ,:unit => unit).is_approved.order_by(sort).filter_by_categories(["all"]) if !unit.nil? - news_count = news.count + news_count = ",共有" + news.count.to_s + "筆資料" keywords = params[:unit].split("-") keywords.delete(keywords.last) @@ -40,7 +40,7 @@ class NewsController < ApplicationController !params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:is_top=>"desc",:postdate=>"desc"} category = Category.find_by(:uid => params["category"].split("-").last) rescue nil news = NewsBulletin.all.where(:title.ne => "").is_approved.order_by(sort).filter_by_categories([category.id.to_s]) if !category.nil? - news_count = news.count + news_count = ",共有" + news.count.to_s + "筆資料" keywords = params[:category].split("-") keywords.delete(keywords.last)