From 5afc74cb831ceed59d946aa05d9d3ea46a81e997 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Fri, 7 Jul 2017 11:47:16 +0800 Subject: [PATCH] filter by categories added --- app/controllers/hps_learnings_controller.rb | 2 +- app/views/admin/hps_learnings/index.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/hps_learnings_controller.rb b/app/controllers/hps_learnings_controller.rb index 2e583e5..9b72504 100644 --- a/app/controllers/hps_learnings_controller.rb +++ b/app/controllers/hps_learnings_controller.rb @@ -2,7 +2,7 @@ class HpsLearningsController < ApplicationController def index table_fields = ["hps_learning.course_pic", "hps_learning.title", :category, "hps_learning.runtime", "hps_learning.lectures"].collect{|x| {"head" => t(x.to_sym)}} classes = [] - HpsClass.all.desc(:created_at).each do |hpsclass| + HpsClass.filter_by_categories.desc(:created_at).each do |hpsclass| if hpsclass.hps_lectures.count > 0 thumb = hpsclass.course_pic.thumb.url.nil? ? "http://www.placehold.it/150x150/EFEFEF/AAAAAA" : hpsclass.course_pic.thumb.url classes << { diff --git a/app/views/admin/hps_learnings/index.html.erb b/app/views/admin/hps_learnings/index.html.erb index 39fd6c6..1a0477b 100644 --- a/app/views/admin/hps_learnings/index.html.erb +++ b/app/views/admin/hps_learnings/index.html.erb @@ -12,7 +12,7 @@ <% if !clas.course_pic.url.nil? %> <% else %> -   + <% end %> <%= clas.title %>