Files
mpa-blog/app/controllers/parties_controller.rb
Wild Karl-Heinz c9bf64dc8c - added parties
- changed layout for index and added svgs
2025-11-22 19:35:58 +01:00

59 lines
1.3 KiB
Ruby

class PartiesController < ApplicationController
before_action :set_party, only: %i[ show edit update destroy ]
def index
@parties = Party.all
end
def show
end
def new
@party = Party.new
end
def edit
end
def create
@party = Party.new(party_params)
respond_to do |format|
if @party.save
format.html { redirect_to parties_path, notice: "Party was successfully created." }
else
format.html { render :new, status: :unprocessable_entity }
end
end
end
def update
respond_to do |format|
if @party.update(party_params)
format.html { redirect_to parties_path, notice: "Party was successfully updated.", status: :see_other }
else
format.html { render :edit, status: :unprocessable_entity }
end
end
end
def destroy
@party.destroy!
respond_to do |format|
format.html { redirect_to parties_path, notice: "Party was successfully destroyed.", status: :see_other }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_party
@party = Party.find(params.expect(:id))
end
# Only allow a list of trusted parameters through.
def party_params
params.expect(party: [ :title, :location, :start_date, :start_time, :status ])
end
end