feat: implement resetting a pop

This commit is contained in:
insects 2025-03-10 23:42:14 +01:00
parent 5c721eb08c
commit 9ff401bdfd
2 changed files with 9 additions and 4 deletions

View file

@ -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

View file

@ -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