check null for image
This commit is contained in:
@@ -115,7 +115,10 @@ class Settings::MenusController < ApplicationController
|
|||||||
i = i + 1
|
i = i + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
image_path = ""
|
||||||
|
if mi.image_path
|
||||||
|
image_path = mi.image_path.to_s.remove("/image/menu_images/")
|
||||||
|
end
|
||||||
options = ""
|
options = ""
|
||||||
i=0
|
i=0
|
||||||
if mi.item_options.length > 0
|
if mi.item_options.length > 0
|
||||||
@@ -135,7 +138,7 @@ class Settings::MenusController < ApplicationController
|
|||||||
if mii.item_attributes.length > 0
|
if mii.item_attributes.length > 0
|
||||||
attribute = MenuItemAttribute.find(mii.item_attributes[0]).name
|
attribute = MenuItemAttribute.find(mii.item_attributes[0]).name
|
||||||
end
|
end
|
||||||
sheet.add_row [ mc.code, mc.name, mi.item_code, mi.name, mi.account.title, mi.alt_name, mi.taxable, attributes, options, mii.item_instance_code, mii.item_instance_name, attribute, mii.price, mii.is_default, mi.image_path.to_s.remove("/image/menu_images/")], :style=>wrap_text
|
sheet.add_row [ mc.code, mc.name, mi.item_code, mi.name, mi.account.title, mi.alt_name, mi.taxable, attributes, options, mii.item_instance_code, mii.item_instance_name, attribute, mii.price, mii.is_default, image_path], :style=>wrap_text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -192,7 +192,10 @@ class Menu < ApplicationRecord
|
|||||||
account = Account.create({title: row["Account"], account_type: "0"})
|
account = Account.create({title: row["Account"], account_type: "0"})
|
||||||
end
|
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)
|
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
|
# else
|
||||||
# status = status + "Item Code already exists for " + row["Item Name"] + "."
|
# status = status + "Item Code already exists for " + row["Item Name"] + "."
|
||||||
|
|||||||
Reference in New Issue
Block a user