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