Class: ChiliPepper::Menu
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ChiliPepper::Menu
- Extended by:
- FriendlyId
- Defined in:
- app/models/chili_pepper/menu.rb
Class Method Summary collapse
- .drinks_menus ⇒ Object
- .food_menus ⇒ Object
- .published ⇒ Object
- .same_type_menus(menu_type) ⇒ Object
Instance Method Summary collapse
Class Method Details
.drinks_menus ⇒ Object
59 60 61 |
# File 'app/models/chili_pepper/menu.rb', line 59 def self. where menu_type: [:drinks] end |
.food_menus ⇒ Object
55 56 57 |
# File 'app/models/chili_pepper/menu.rb', line 55 def self. where menu_type: [:food] end |
.published ⇒ Object
51 52 53 |
# File 'app/models/chili_pepper/menu.rb', line 51 def self.published where published: true end |
.same_type_menus(menu_type) ⇒ Object
63 64 65 66 67 |
# File 'app/models/chili_pepper/menu.rb', line 63 def self.() where(menu_type: []) .select('id, name, slug, position, menu_type, published') .order('position') end |
Instance Method Details
#duplicate ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/models/chili_pepper/menu.rb', line 73 def duplicate = Menu.create!(name: "#{name} copy", menu_type: ) sections.each do |original_section| new_section = original_section.dup new_section. = .id new_section.save original_section.items.each do |item| Item.create!( section_id: new_section.id, dish_id: item.dish_id, column: item.column, position: item.position ) end end end |
#food_menu? ⇒ Boolean
69 70 71 |
# File 'app/models/chili_pepper/menu.rb', line 69 def == 'food' end |