title check for category creation

This commit is contained in:
Harry Bomrah 2016-02-16 14:53:28 +08:00
parent 3abcd5a09a
commit afb9be2d07
1 changed files with 14 additions and 2 deletions

View File

@ -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)