From 9ff401bdfd4658e17e77625cab5d66e191bbfab9 Mon Sep 17 00:00:00 2001 From: insects Date: Mon, 10 Mar 2025 23:42:14 +0100 Subject: [PATCH] feat: implement resetting a pop --- app/controllers/instance_controller.rb | 8 ++++++++ config/routes.rb | 5 +---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/controllers/instance_controller.rb b/app/controllers/instance_controller.rb index 9a39c6c..35b226b 100644 --- a/app/controllers/instance_controller.rb +++ b/app/controllers/instance_controller.rb @@ -24,6 +24,14 @@ class InstanceController < ApplicationController end end + def reset + instance_id, nm = pop_instance_params + parent_instance = Instance.find_by(public_id: instance_id) + Pop.delete_by(instance_id: parent_instance.id, name: nm) + @instance = Instance.includes(:pops).find_by(public_id: instance_id) + render partial: "list", locals: { instance: @instance } + end + private def create_instance_params diff --git a/config/routes.rb b/config/routes.rb index e9487da..144da81 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,10 +4,7 @@ Rails.application.routes.draw do post "/new", to: "instance#create", as: :new_instance get "/:public_id", to: "instance#show", as: :show_instance post "/pop", to: "instance#pop", as: :pop_in_instance + post "/reset", to: "instance#reset", as: :reset_in_instance get "up" => "rails/health#show", as: :rails_health_check - - # Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb) - # get "manifest" => "rails/pwa#manifest", as: :pwa_manifest - # get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker end