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?