Allow to destroy SDG local targets

This commit is contained in:
Senén Rodero Rodríguez
2020-11-25 15:25:51 +01:00
parent a211937744
commit 8f7809ddb4
6 changed files with 26 additions and 3 deletions

View File

@@ -24,7 +24,7 @@ class SDGManagement::LocalTargets::IndexComponent < ApplicationComponent
def actions(local_target)
render Admin::TableActionsComponent.new(
local_target,
actions: [:edit],
edit_path: edit_sdg_management_local_target_path(local_target))
edit_path: edit_sdg_management_local_target_path(local_target),
destroy_path: sdg_management_local_target_path(local_target))
end
end

View File

@@ -35,6 +35,12 @@ class SDGManagement::LocalTargetsController < SDGManagement::BaseController
end
end
def destroy
@local_target = LocalTarget.find(params[:id])
@local_target.destroy!
redirect_to sdg_management_local_targets_path, notice: t("sdg_management.local_targets.destroy.notice")
end
private
def local_target_params