Class: Admin::MenusController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/menus_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



17
18
19
20
21
22
# File 'app/controllers/admin/menus_controller.rb', line 17

def create
  add_breadcrumb 'New', :new_admin_menu_path
  @menu = SpudMenu.new(menu_params)
  flash[:notice] = 'New menu created' if @menu.save
  respond_with @menu, location: !@menu.id.nil? ? admin_menu_menu_items_url(menu_id: @menu.id) : admin_menus_url
end

#destroyObject



36
37
38
39
# File 'app/controllers/admin/menus_controller.rb', line 36

def destroy
  flash[:notice] = 'Menu removed!' if @menu.destroy
  respond_with @menu, location: admin_menus_url
end

#editObject



24
25
26
27
# File 'app/controllers/admin/menus_controller.rb', line 24

def edit
  add_breadcrumb "Edit #{@menu.name}", :edit_admin_menu_path
  respond_with @menu
end

#indexObject



6
7
8
9
# File 'app/controllers/admin/menus_controller.rb', line 6

def index
  @menus = SpudMenu.all.paginate(page: params[:page])
  respond_with @menus
end

#newObject



11
12
13
14
15
# File 'app/controllers/admin/menus_controller.rb', line 11

def new
  add_breadcrumb 'New', :new_admin_menu_path
  @menu = SpudMenu.new
  respond_with @menu
end

#updateObject



29
30
31
32
33
34
# File 'app/controllers/admin/menus_controller.rb', line 29

def update
  add_breadcrumb "Edit #{@menu.name}", :edit_admin_menu_path

  flash[:notice] = 'Menu saved successfully' if @menu.update_attributes(menu_params)
  respond_with @menu, location: admin_menu_menu_items_url(menu_id: @menu.id)
end