a11yist/app/controllers/success_criteria_controller.rb

65 lines
1.7 KiB
Ruby
Raw Normal View History

class SuccessCriteriaController < ApplicationController
2024-07-19 02:29:18 +02:00
before_action :set_success_criterion, only: %i[show edit update destroy]
# GET /success_criteria
def index
@success_criteria = SuccessCriterion.all
end
# GET /success_criteria/1
def show
end
# GET /success_criteria/new
def new
@success_criterion = SuccessCriterion.new
end
# GET /success_criteria/1/edit
def edit
end
# POST /success_criteria
def create
@success_criterion = SuccessCriterion.new(success_criterion_params)
if @success_criterion.save
2024-07-19 02:29:18 +02:00
redirect_to @success_criterion, notice: 'Success criterion was successfully created.'
else
render :new, status: :unprocessable_entity
end
end
# PATCH/PUT /success_criteria/1
def update
if @success_criterion.update(success_criterion_params)
2024-07-19 02:29:18 +02:00
redirect_to @success_criterion, notice: 'Success criterion was successfully updated.', status: :see_other
else
render :edit, status: :unprocessable_entity
end
end
# DELETE /success_criteria/1
def destroy
@success_criterion.destroy!
2024-07-22 22:40:56 +02:00
respond_to do |format|
format.html do
redirect_to success_criteria_url, notice: 'Success criterion was successfully destroyed.', status: :see_other
end
format.turbo_stream
end
end
private
2024-07-19 02:29:18 +02:00
# Use callbacks to share common setup or constraints between actions.
def set_success_criterion
@success_criterion = SuccessCriterion.find(params[:id])
end
# Only allow a list of trusted parameters through.
def success_criterion_params
params.require(:success_criterion).permit(:element_id, :title, :description_html, :level, :result, :comment_html)
end
end