class MenuItemInstance < ApplicationRecord belongs_to :menu_item 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 end