badar_madeena/app/controllers/ziyaras_controller.rb

71 lines
1.9 KiB
Ruby

class ZiyarasController < ApplicationController
before_action :set_ziyara, only: %i[ show edit update destroy ]
# GET /ziyaras or /ziyaras.json
def index
@ziyaras = Ziyara.all
end
# GET /ziyaras/1 or /ziyaras/1.json
def show
end
# GET /ziyaras/new
def new
@ziyara = Ziyara.new
end
# GET /ziyaras/1/edit
def edit
end
# POST /ziyaras or /ziyaras.json
def create
@ziyara = Ziyara.new(ziyara_params)
respond_to do |format|
if @ziyara.save
format.html { redirect_to @ziyara, notice: "Ziyara was successfully created." }
format.json { render :show, status: :created, location: @ziyara }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @ziyara.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /ziyaras/1 or /ziyaras/1.json
def update
respond_to do |format|
if @ziyara.update(ziyara_params)
format.html { redirect_to @ziyara, notice: "Ziyara was successfully updated.", status: :see_other }
format.json { render :show, status: :ok, location: @ziyara }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @ziyara.errors, status: :unprocessable_entity }
end
end
end
# DELETE /ziyaras/1 or /ziyaras/1.json
def destroy
@ziyara.destroy!
respond_to do |format|
format.html { redirect_to ziyaras_path, notice: "Ziyara was successfully destroyed.", status: :see_other }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_ziyara
@ziyara = Ziyara.find(params[:id])
end
# Only allow a list of trusted parameters through.
def ziyara_params
params.require(:ziyara).permit(:name, :date, :location, :description)
end
end