70 lines
2 KiB
Ruby
70 lines
2 KiB
Ruby
class MenuOptionsController < ApplicationController
|
|
before_action :set_menu_option, only: %i[ show edit update destroy ]
|
|
|
|
# GET /menu_options or /menu_options.json
|
|
def index
|
|
@menu_options = MenuOption.all
|
|
end
|
|
|
|
# GET /menu_options/1 or /menu_options/1.json
|
|
def show
|
|
end
|
|
|
|
# GET /menu_options/new
|
|
def new
|
|
@menu_option = MenuOption.new
|
|
end
|
|
|
|
# GET /menu_options/1/edit
|
|
def edit
|
|
end
|
|
|
|
# POST /menu_options or /menu_options.json
|
|
def create
|
|
@menu_option = MenuOption.new(menu_option_params)
|
|
|
|
respond_to do |format|
|
|
if @menu_option.save
|
|
format.html { redirect_to menu_option_url(@menu_option), notice: "Menu option was successfully created." }
|
|
format.json { render :show, status: :created, location: @menu_option }
|
|
else
|
|
format.html { render :new, status: :unprocessable_entity }
|
|
format.json { render json: @menu_option.errors, status: :unprocessable_entity }
|
|
end
|
|
end
|
|
end
|
|
|
|
# PATCH/PUT /menu_options/1 or /menu_options/1.json
|
|
def update
|
|
respond_to do |format|
|
|
if @menu_option.update(menu_option_params)
|
|
format.html { redirect_to menu_option_url(@menu_option), notice: "Menu option was successfully updated." }
|
|
format.json { render :show, status: :ok, location: @menu_option }
|
|
else
|
|
format.html { render :edit, status: :unprocessable_entity }
|
|
format.json { render json: @menu_option.errors, status: :unprocessable_entity }
|
|
end
|
|
end
|
|
end
|
|
|
|
# DELETE /menu_options/1 or /menu_options/1.json
|
|
def destroy
|
|
@menu_option.destroy
|
|
|
|
respond_to do |format|
|
|
format.html { redirect_to menu_options_url, notice: "Menu option was successfully destroyed." }
|
|
format.json { head :no_content }
|
|
end
|
|
end
|
|
|
|
private
|
|
# Use callbacks to share common setup or constraints between actions.
|
|
def set_menu_option
|
|
@menu_option = MenuOption.find(params[:id])
|
|
end
|
|
|
|
# Only allow a list of trusted parameters through.
|
|
def menu_option_params
|
|
params.require(:menu_option).permit(:menu_id, :batch_id)
|
|
end
|
|
end
|