Class: Panda::CMS::Admin::MenusController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/panda/cms/admin/menus_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#set_current_request_details

Methods included from Panda::CMS::ApplicationHelper

#active_link?, #block_link_to, #component, #level_indent, #menu_indent, #nav_class, #nav_highlight_colour_classes, #panda_cms_collection, #panda_cms_collection_items, #panda_cms_editor, #panda_cms_feature_enabled?, #panda_cms_form_with, #selected_nav_highlight_colour_classes, #table_indent, #title_tag

Instance Method Details

#createObject



26
27
28
29
30
31
32
33
34
# File 'app/controllers/panda/cms/admin/menus_controller.rb', line 26

def create
  menu = Panda::CMS::Menu.new(menu_params)

  if menu.save
    redirect_to admin_cms_menus_path, notice: "Menu was successfully created."
  else
    render :new, locals: {menu: menu}, status: :unprocessable_entity
  end
end

#destroyObject



52
53
54
55
# File 'app/controllers/panda/cms/admin/menus_controller.rb', line 52

def destroy
  @menu.destroy
  redirect_to admin_cms_menus_path, notice: "Menu was successfully deleted."
end

#editObject



37
38
39
40
# File 'app/controllers/panda/cms/admin/menus_controller.rb', line 37

def edit
  add_breadcrumb @menu.name, edit_admin_cms_menu_path(@menu)
  render :edit
end

#indexObject

Lists all menus which can be managed by the administrator

Returns:

  • ActiveRecord::Collection An array of all menus



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

def index
  menus = Panda::CMS::Menu.order(:name)
  render :index, locals: {menus: menus}
end

#newObject



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

def new
  menu = Panda::CMS::Menu.new
  add_breadcrumb "New Menu", new_admin_cms_menu_path
  render :new, locals: {menu: menu}
end

#updateObject



43
44
45
46
47
48
49
# File 'app/controllers/panda/cms/admin/menus_controller.rb', line 43

def update
  if @menu.update(menu_params)
    redirect_to admin_cms_menus_path, notice: "Menu was successfully updated."
  else
    render :edit, status: :unprocessable_entity
  end
end