Class: MenusController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#check_route, #current_ability, #set_current_user

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/menus_controller.rb', line 20

def create
  @menu = Menu.new(menu_params)
  respond_to do |format|
    if @menu.save
      format.html{ redirect_to menus_path }
    else
      format.html{ render :new }
    end
  end
end

#destroyObject



44
45
46
47
48
49
50
# File 'app/controllers/menus_controller.rb', line 44

def destroy
  respond_to do |format|
    Menu.where(parent_id: @menu.id).destroy_all
    @menu.destroy
    format.html{ redirect_to menus_path }
  end
end

#editObject



31
32
# File 'app/controllers/menus_controller.rb', line 31

def edit
end

#indexObject



4
5
6
7
# File 'app/controllers/menus_controller.rb', line 4

def index
  # @menus = Menu.orderByParent.page(params[:page]).per(1)
  @menus = Menu.orderByParent
end

#newObject



13
14
15
16
17
18
# File 'app/controllers/menus_controller.rb', line 13

def new
  @menu = Menu.new
  if params[:parent_id]
    @menu.parent_id = params[:parent_id]
  end
end

#showObject



9
10
11
# File 'app/controllers/menus_controller.rb', line 9

def show
  @menus = Menu.where(parent_id: @menu.id)
end

#updateObject



34
35
36
37
38
39
40
41
42
# File 'app/controllers/menus_controller.rb', line 34

def update
  respond_to do |format|
    if @menu.update(menu_params)
      format.html{ redirect_to menus_path }
    else
      format.html{ render :edit }
    end
  end
end