osaka menu rake

This commit is contained in:
Yan
2017-07-11 19:21:17 +06:30
parent 39aca095fb
commit b47e0d0548
4 changed files with 63 additions and 65 deletions

View File

@@ -1,5 +1,4 @@
class MenuCategory < ApplicationRecord
class MenuCategory < ApplicationRecord
before_create :generate_menu_category_code
belongs_to :menu
@@ -7,7 +6,7 @@ class MenuCategory < ApplicationRecord
belongs_to :parent, :class_name => "MenuCategory", foreign_key: "menu_category_id", optional: true
has_many :menu_items
validates_presence_of :name, :menu, :code, :order_by
validates_presence_of :name, :menu, :order_by
default_scope { order('order_by asc') }
@@ -38,7 +37,7 @@ class MenuCategory < ApplicationRecord
private
def generate_menu_category_code
self.code = SeedGenerator.generate_code(self.class.name, "C")
def generate_menu_category_code
self.code = SeedGenerator.generate_code(self.class.name, "C")
end
end

View File

@@ -8,7 +8,7 @@ class MenuItem < ApplicationRecord
has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
belongs_to :account
validates_presence_of :item_code, :name, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item
validates_presence_of :name, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item
default_scope { order('item_code asc') }

View File

@@ -61,8 +61,7 @@ class SeedGenerator < ApplicationRecord
end
padding_len = 5 - prefix.length
next_code = prefix +"-"+ seed.current.to_s.to_s.rjust((4-prefix.length)+1,'0')
next_code = prefix + seed.current.to_s.to_s.rjust((4-prefix.length)+1,'0')
return next_code
end
end