Class: Admin::MenusController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  add_breadcrumb "New", :new_admin_menu_path
  @menu = SpudMenu.new(menu_params)
  @menu.site_id = session[:admin_site]
  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



38
39
40
41
# File 'app/controllers/admin/menus_controller.rb', line 38

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

#editObject



26
27
28
29
# File 'app/controllers/admin/menus_controller.rb', line 26

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.site(session[:admin_site]).order(:name).paginate :page => params[:page]
  respond_with @menus
end

#newObject



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

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

#updateObject



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

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