From 45e21f9569afcc5736738f2fdd905a9b5979399d Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 2 May 2012 17:55:02 +0800 Subject: [PATCH] Fix filter category in news --- app/controllers/orbit_backend_controller.rb | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/app/controllers/orbit_backend_controller.rb b/app/controllers/orbit_backend_controller.rb index 15afe963..8655e93f 100644 --- a/app/controllers/orbit_backend_controller.rb +++ b/app/controllers/orbit_backend_controller.rb @@ -62,30 +62,23 @@ class OrbitBackendController< ApplicationController case key when 'status' a = Array.new - objects.each do |bulletin| + objects.each do |object| value.each do |v| - case v - when 'pending' - a << bulletin if bulletin.is_checked.nil? - when 'rejected' - a << bulletin if bulletin.is_checked.eql?(false) - else - a << bulletin if bulletin[v] - end + a << object if object[v] end end objects = a.uniq when 'categories' a = Array.new - objects.each do |bulletin| - a << bulletin if value.include?(bulletin.bulletin_category.id.to_s) + objects.each do |object| + a << object if value.include?(object.send("#{object.class.to_s.underscore}_category").id.to_s) end objects = a.uniq when 'tags' a = Array.new - objects.each do |bulletin| - bulletin.tags.each do |tag| - a << bulletin if value.include?(tag.id.to_s) + objects.each do |object| + object.tags.each do |tag| + a << object if value.include?(tag.id.to_s) end end objects = a.uniq