From 00d45ab08e9ba874ff924793a3216e52742e3f3c Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Tue, 12 Jan 2016 20:33:53 +0800 Subject: [PATCH] removed blank columns --- app/models/course.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/models/course.rb b/app/models/course.rb index e07809f..63a3c7e 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -40,12 +40,19 @@ class Course "year", ] - pd_title = fields_to_show.collect do |t| - { - "plugin_data_title" => I18n.t("personal_course.#{t}") - } + fields_to_remove = [] + + pd_title = [] + + fields_to_show.each do |t| + fields_to_remove << t if (datas.where(t.to_sym.ne => nil, t.to_sym.ne => "").count == 0 rescue false) + pd_title << { + "plugin_data_title" => I18n.t("personal_course.#{t}") + } if !fields_to_remove.include?(t) end + fields_to_show = fields_to_show - fields_to_remove + plugin_datas = datas.sort_for_frontend.collect.with_index do |p,index| pd_data = []