update menu

This commit is contained in:
Yan
2017-08-11 15:00:24 +06:30
parent 12d3e70b19
commit be71d187b0
6 changed files with 19 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
class MenuCategory < ApplicationRecord class MenuCategory < ApplicationRecord
before_create :generate_menu_category_code # before_create :generate_menu_category_code
belongs_to :menu belongs_to :menu
has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id" has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id"
@@ -37,7 +37,7 @@ class MenuCategory < ApplicationRecord
private private
def generate_menu_category_code # def generate_menu_category_code
self.code = SeedGenerator.generate_code(self.class.name, "C") # self.code = SeedGenerator.generate_code(self.class.name, "C")
end # end
end end

View File

@@ -1,6 +1,5 @@
class MenuItem < ApplicationRecord class MenuItem < ApplicationRecord
# before_create :generate_menu_item_code
before_create :generate_menu_item_code
belongs_to :menu_category, :optional => true belongs_to :menu_category, :optional => true
has_many :menu_item_instances has_many :menu_item_instances
@@ -73,10 +72,10 @@ class MenuItem < ApplicationRecord
end end
private # private
def generate_menu_item_code # def generate_menu_item_code
self.item_code = SeedGenerator.generate_code(self.class.name, "I") # self.item_code = SeedGenerator.generate_code(self.class.name, "I")
end # end
end end

View File

@@ -1,6 +1,6 @@
class MenuItemInstance < ApplicationRecord class MenuItemInstance < ApplicationRecord
belongs_to :menu_item belongs_to :menu_item
before_create :generate_menu_item_instance_code # before_create :generate_menu_item_instance_code
def self.findParentCategory(item) def self.findParentCategory(item)
if item.menu_category_id if item.menu_category_id
@@ -11,9 +11,9 @@ class MenuItemInstance < ApplicationRecord
end end
end end
private # private
def generate_menu_item_instance_code # def generate_menu_item_instance_code
self.item_instance_code = SeedGenerator.generate_code(self.class.name, "II") # self.item_instance_code = SeedGenerator.generate_code(self.class.name, "II")
end # end
end end

View File

@@ -1,6 +1,6 @@
<div class="page-header"> <div class="page-header">
<ul class="breadcrumb"> <ul class="breadcrumb">
<li><a href="<%= %>">Home</a></li> <li><a href="<%= settings_menus_path %>">Home</a></li>
<li><a href="<%= settings_menu_categories_path %>">Menus Categories</a></li> <li><a href="<%= settings_menu_categories_path %>">Menus Categories</a></li>
<li>Details</li> <li>Details</li>
<span style="float: right"> <span style="float: right">

View File

@@ -1,8 +1,8 @@
class CreateMenuItemSets < ActiveRecord::Migration[5.1] class CreateMenuItemSets < ActiveRecord::Migration[5.1]
def change def change
create_table :menu_item_sets do |t| create_table :menu_item_sets do |t|
t.references :item_set_id, foreign_key: true t.references :item_set, foreign_key: true
t.references :menu_item_id, foreign_key: true t.references :menu_item, foreign_key: true
t.timestamps t.timestamps
end end

View File

@@ -1,8 +1,8 @@
class CreateMenuInstanceItemSets < ActiveRecord::Migration[5.1] class CreateMenuInstanceItemSets < ActiveRecord::Migration[5.1]
def change def change
create_table :menu_instance_item_sets do |t| create_table :menu_instance_item_sets do |t|
t.references :item_set_id, foreign_key: true t.references :item_set, foreign_key: true
t.references :menu_item_instance_id, foreign_key: true t.references :menu_item_instance, foreign_key: true
t.timestamps t.timestamps
end end