field object type check

This commit is contained in:
Harry Bomrah 2016-01-13 18:44:28 +08:00
parent b5bc4bb7b2
commit d87942c57c
1 changed files with 16 additions and 5 deletions

View File

@ -49,11 +49,22 @@ class Diploma
"duration" "duration"
] ]
pd_title = fields_to_show.collect do |t| fields_to_remove = []
{
"plugin_data_title" => I18n.t("personal_diploma.#{t}") pd_title = []
}
fields_to_show.each do |t|
if (self.fields[t].type.to_s == "String" || self.fields[t].type.to_s == "Object" rescue false)
fields_to_remove << t if (datas.where(t.to_sym.ne => nil, t.to_sym.ne => "").count == 0 rescue false)
else
fields_to_remove << t if (datas.where(t.to_sym.ne => nil).count == 0 rescue false)
end end
pd_title << {
"plugin_data_title" => I18n.t("personal_diploma.#{t}")
} if !fields_to_remove.include?(t)
end
fields_to_show = fields_to_show - fields_to_remove
plugin_datas = datas.sort_for_frontend.collect do |p| plugin_datas = datas.sort_for_frontend.collect do |p|