Files
sx-fc/app/controllers/dining_charges_controller.rb
2017-08-11 13:34:30 +06:30

75 lines
2.1 KiB
Ruby

class DiningChargesController < ApplicationController
before_action :set_dining_charge, only: [:show, :edit, :update, :destroy]
# GET /dining_charges
# GET /dining_charges.json
def index
@dining_charges = DiningCharge.all
end
# GET /dining_charges/1
# GET /dining_charges/1.json
def show
end
# GET /dining_charges/new
def new
@dining_charge = DiningCharge.new
end
# GET /dining_charges/1/edit
def edit
end
# POST /dining_charges
# POST /dining_charges.json
def create
@dining_charge = DiningCharge.new(dining_charge_params)
respond_to do |format|
if @dining_charge.save
format.html { redirect_to @dining_charge, notice: 'Dining charge was successfully created.' }
format.json { render :show, status: :created, location: @dining_charge }
else
format.html { render :new }
format.json { render json: @dining_charge.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /dining_charges/1
# PATCH/PUT /dining_charges/1.json
def update
respond_to do |format|
if @dining_charge.update(dining_charge_params)
format.html { redirect_to @dining_charge, notice: 'Dining charge was successfully updated.' }
format.json { render :show, status: :ok, location: @dining_charge }
else
format.html { render :edit }
format.json { render json: @dining_charge.errors, status: :unprocessable_entity }
end
end
end
# DELETE /dining_charges/1
# DELETE /dining_charges/1.json
def destroy
@dining_charge.destroy
respond_to do |format|
format.html { redirect_to dining_charges_url, notice: 'Dining charge was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_dining_charge
@dining_charge = DiningCharge.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def dining_charge_params
params.fetch(:dining_charge, {})
end
end