a11yist/app/controllers/checklist_entries_controller.rb
david 63fc206c27
Some checks failed
/ Run tests (push) Successful in 8m56s
/ Run system tests (push) Failing after 1h0m48s
/ Build, push and deploy image (push) Successful in 7m47s
A lot :)
2024-09-05 22:54:38 +02:00

65 lines
1.7 KiB
Ruby

# frozen_string_literal: true
class ChecklistEntriesController < ApplicationController
before_action :set_checklist_entry, only: %i[show edit update destroy]
# GET /checklist_entries
def index
@checklist_entries = ChecklistEntry.all
end
# GET /checklist_entries/1
def show; end
# GET /checklist_entries/new
def new
@checklist_entry = ChecklistEntry.new(checklist_id: params[:checklist_id])
end
# GET /checklist_entries/1/edit
def edit; end
# POST /checklist_entries
def create
@checklist_entry = ChecklistEntry.new(checklist_entry_params)
if @checklist_entry.save
redirect_to @checklist_entry.checklist, notice: "Checklist entry was successfully created."
else
render :new, status: :unprocessable_entity
end
end
# PATCH/PUT /checklist_entries/1
def update
if @checklist_entry.update(checklist_entry_params)
redirect_to @checklist_entry.checklist, notice: "Checklist entry was successfully updated.",
status: :see_other
else
render :edit, status: :unprocessable_entity
end
end
# DELETE /checklist_entries/1
def destroy
@checklist_entry.destroy!
respond_to do |format|
format.html do
redirect_to checklist_entries_url, notice: "Checklist entry was successfully destroyed.", status: :see_other
end
format.turbo_stream
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_checklist_entry
@checklist_entry = ChecklistEntry.find(params[:id])
end
# Only allow a list of trusted parameters through.
def checklist_entry_params
params.require(:checklist_entry).permit(:checklist_id, :check_id, :position)
end
end