Class: ChiliPepper::DishesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
# File 'app/controllers/chili_pepper/dishes_controller.rb', line 16

def create
  @dish = Dish.new(dish_params)
  if @dish.save!
    redirect_to_menu_section
  else
    render action: :new
  end
end

#destroyObject



36
37
38
39
# File 'app/controllers/chili_pepper/dishes_controller.rb', line 36

def destroy
  @dish.destroy
  redirect_to_menu_section
end

#editObject



25
26
# File 'app/controllers/chili_pepper/dishes_controller.rb', line 25

def edit
end

#newObject



11
12
13
14
# File 'app/controllers/chili_pepper/dishes_controller.rb', line 11

def new
  @dish = Dish.new
  @item = build_item
end

#updateObject



28
29
30
31
32
33
34
# File 'app/controllers/chili_pepper/dishes_controller.rb', line 28

def update
  if @dish.update(dish_params)
    redirect_to_menu_section
  else
    render action: :edit
  end
end