module Api module V1 module Admin class TrainingWatchSourcesController < BaseController before_action :set_source, only: %i[show update destroy] def index = render json: TrainingWatchSource.order(:name) def show = render json: @source def create source = TrainingWatchSource.new(source_params) source.save ? render(json: source, status: :created) : render_validation(source) end def update @source.update(source_params) ? render(json: @source) : render_validation(@source) end def destroy @source.destroy! head :no_content end private def set_source = @source = TrainingWatchSource.find(params[:id]) def source_params = params.require(:training_watch_source).permit(:name, :url, :kind, :match_regex, :enabled) end end end end