From 0d4b01b2b07f75e6c41770fa50de5105afc12346 Mon Sep 17 00:00:00 2001 From: fauno Date: Sat, 31 Aug 2019 12:29:48 -0300 Subject: [PATCH] Mostrar en la API si un consenso se puede eliminar --- app/controllers/consensos_controller.rb | 2 +- app/views/consensos/_consenso.json.jbuilder | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/consensos_controller.rb b/app/controllers/consensos_controller.rb index 804aba5..e877be2 100644 --- a/app/controllers/consensos_controller.rb +++ b/app/controllers/consensos_controller.rb @@ -66,7 +66,7 @@ class ConsensosController < ApplicationController def destroy @consenso = @barca.consensos.find(params[:id]) - if @consenso.posiciones.empty? && @consenso.destroy + if @consenso.posiciones.count.zero? && @consenso.destroy notify(subject: :destroy) render status: :ok else diff --git a/app/views/consensos/_consenso.json.jbuilder b/app/views/consensos/_consenso.json.jbuilder index 1a188da..d29d2be 100644 --- a/app/views/consensos/_consenso.json.jbuilder +++ b/app/views/consensos/_consenso.json.jbuilder @@ -9,3 +9,5 @@ posiciones = consenso.posiciones posiciones = posiciones.ultimas if ultimas json.posiciones posiciones, partial: 'posiciones/posicion', as: :posicion + +json.eliminable consenso.posiciones.count.zero?