check null for image

This commit is contained in:
San Wai Lwin
2018-06-22 14:51:53 +06:30
parent 4dfed88bb4
commit 79bafadd1b
2 changed files with 9 additions and 3 deletions

View File

@@ -192,7 +192,10 @@ class Menu < ApplicationRecord
account = Account.create({title: row["Account"], account_type: "0"})
end
image_path = row["Image Path"] ? URI.parse('public/image/menu_images/'+row["Image Path"]) : ""
image_path = ""
if row["Image Path"] != ""
image_path = URI.parse('public/image/menu_images/'+row["Image Path"])
end
menu_itm = MenuItem.create(item_code: row["Item Code"], name: row["Item Name"], account_id: account.id, alt_name: row["Item AltName"], image_path: image_path, description: '', information: '', unit: '', type: "SimpleMenuItem", menu_category_id: menu_cat.id, item_attributes: item_attrs, item_options: item_opts, is_sub_item: 0, is_available: 1, created_by: created_by)
# else
# status = status + "Item Code already exists for " + row["Item Name"] + "."