From afb9be2d0723b845fa481365b6f83c1aa8f99708 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Tue, 16 Feb 2016 14:53:28 +0800 Subject: [PATCH] title check for category creation --- .../admin/universal_tables_controller.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/universal_tables_controller.rb b/app/controllers/admin/universal_tables_controller.rb index d8aa01b..1c0138a 100644 --- a/app/controllers/admin/universal_tables_controller.rb +++ b/app/controllers/admin/universal_tables_controller.rb @@ -158,7 +158,13 @@ class Admin::UniversalTablesController < OrbitAdminController def create category = Category.new - category.title_translations = params[:u_table][:title_translations] + title_for_category = params[:u_table][:title_translations] + if title_for_category["en"] == "" && title_for_category["zh_tw"] != "" + title_for_category["en"] = title_for_category["zh_tw"] + elsif title_for_category["zh_tw"] == "" && title_for_category["en"] != "" + title_for_category["zh_tw"] = title_for_category["en"] + end + category.title_translations = title_for_category category.module_app = @module_app category.save p = table_params @@ -182,7 +188,13 @@ class Admin::UniversalTablesController < OrbitAdminController cat = Category.new cat.module_app = @module_app end - cat.title_translations = p[:title_translations] + title_for_category = p[:title_translations] + if title_for_category["en"] == "" && title_for_category["zh_tw"] != "" + title_for_category["en"] = title_for_category["zh_tw"] + elsif title_for_category["zh_tw"] == "" && title_for_category["en"] != "" + title_for_category["zh_tw"] = title_for_category["en"] + end + cat.title_translations = title_for_category cat.save p[:category_id] = cat.id table.update_attributes(p)