20 lines
469 B
Ruby
20 lines
469 B
Ruby
class MenuItemInstance < ApplicationRecord
|
|
belongs_to :menu_item
|
|
before_create :generate_menu_item_instance_code
|
|
|
|
def self.findParentCategory(item)
|
|
if item.menu_category_id
|
|
return item.menu_category_id
|
|
else
|
|
parentitem = MenuItem.find(item.menu_item_id)
|
|
findParentCategory(parentitem)
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def generate_menu_item_instance_code
|
|
self.item_instance_code = SeedGenerator.generate_id(self.class.name, "II")
|
|
end
|
|
end
|