Class: Admin::Odania::MenuItemsController
- Inherits:
-
AdminController
- Object
- AdminController
- Admin::Odania::MenuItemsController
- Defined in:
- app/controllers/admin/odania/menu_items_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /odania/menu_items.
-
#destroy ⇒ Object
DELETE /odania/menu_items/1.
-
#edit ⇒ Object
GET /odania/menu_items/1/edit.
-
#index ⇒ Object
GET /odania/menu_items.
-
#new ⇒ Object
GET /odania/menu_items/new.
- #overview ⇒ Object
- #set_default ⇒ Object
-
#show ⇒ Object
GET /odania/menu_items/1.
-
#update ⇒ Object
PATCH/PUT /odania/menu_items/1.
Instance Method Details
#create ⇒ Object
POST /odania/menu_items
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/admin/odania/menu_items_controller.rb', line 24 def create Odania::MenuItem.transaction do @odania_menu_item = Odania::MenuItem.new() @odania_menu_item.target_data = odania_target_data_params @odania_menu_item. = @odania_menu.id if @odania_menu_item.save redirect_to (@odania_menu), notice: 'Menu item was successfully created.' else render action: 'new' end end end |
#destroy ⇒ Object
DELETE /odania/menu_items/1
51 52 53 54 55 56 57 |
# File 'app/controllers/admin/odania/menu_items_controller.rb', line 51 def destroy Odania::MenuItem.transaction do @odania_menu_item.destroy end redirect_to (@odania_menu), notice: 'Menu item was successfully destroyed.' end |
#edit ⇒ Object
GET /odania/menu_items/1/edit
20 21 |
# File 'app/controllers/admin/odania/menu_items_controller.rb', line 20 def edit end |
#index ⇒ Object
GET /odania/menu_items
5 6 7 |
# File 'app/controllers/admin/odania/menu_items_controller.rb', line 5 def index @odania_menu_items = @odania_menu..order('parent_id ASC') end |
#new ⇒ Object
GET /odania/menu_items/new
14 15 16 17 |
# File 'app/controllers/admin/odania/menu_items_controller.rb', line 14 def new @odania_menu_item = Odania::MenuItem.new @odania_menu_item.target_type = Odania::TargetType.targets.keys.first end |
#overview ⇒ Object
66 67 68 69 70 71 |
# File 'app/controllers/admin/odania/menu_items_controller.rb', line 66 def overview = Odania::Menu.first redirect_to , notice: 'Create a menu first' if .nil? redirect_to (menu_id: .id.to_s) end |
#set_default ⇒ Object
59 60 61 62 63 64 |
# File 'app/controllers/admin/odania/menu_items_controller.rb', line 59 def set_default @odania_menu. = @odania_menu_item.id @odania_menu.save! redirect_to (@odania_menu), notice: 'Menu item set to default.' end |
#show ⇒ Object
GET /odania/menu_items/1
10 11 |
# File 'app/controllers/admin/odania/menu_items_controller.rb', line 10 def show end |
#update ⇒ Object
PATCH/PUT /odania/menu_items/1
39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/admin/odania/menu_items_controller.rb', line 39 def update Odania::MenuItem.transaction do @odania_menu_item.target_data = odania_target_data_params if @odania_menu_item.update() redirect_to (@odania_menu), notice: 'Menu item was successfully updated.' else render action: 'edit' end end end |