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