no multiplicar los arduinos

This commit is contained in:
f 2022-05-14 18:36:04 -03:00
parent 3a1b78f238
commit e085d5345d

View file

@ -21,7 +21,7 @@ class ReadingsController < ActionController::API
params[:arduinos]&.reject do |a| params[:arduinos]&.reject do |a|
a[:id].blank? || a[:sensores].empty? a[:id].blank? || a[:sensores].empty?
end&.each do |a| end&.each do |a|
arduino = reading.arduinos.build local_id: a[:id], raspberry: raspberry arduino = reading.arduinos.find_or_initialize_by(local_id: a[:id], raspberry: raspberry)
a[:sensores].each do |s| a[:sensores].each do |s|
arduino.sensors.build(sensor_params s) arduino.sensors.build(sensor_params s)