From 38bbeceab4f3d5e7ec6ee96e765740fe671b628a Mon Sep 17 00:00:00 2001 From: f Date: Mon, 21 Mar 2022 14:35:42 -0300 Subject: [PATCH] =?UTF-8?q?rechazar=20los=20sensores=20vac=C3=ADos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit puede pasar que los arduinos no respondan --- app/controllers/readings_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/readings_controller.rb b/app/controllers/readings_controller.rb index a558fcc..394935f 100644 --- a/app/controllers/readings_controller.rb +++ b/app/controllers/readings_controller.rb @@ -18,10 +18,12 @@ class ReadingsController < ActionController::API reading.raw_transaction = request.raw_post reading.verified = reading.verify_ssh_signature - params[:arduinos]&.each do |a| + params[:arduinos]&.reject do |a| + a[:id].blank? || a[:sensores].empty? + end&.each do |a| arduino = reading.arduinos.build local_id: a[:id], raspberry: raspberry - a[:sensores]&.each do |s| + a[:sensores].each do |s| arduino.sensors.build(sensor_params s) end end