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)