no es necesario volver a filtrar por raspberry
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
4d6c69be51
commit
4271bd0347
1 changed files with 3 additions and 3 deletions
|
@ -1,8 +1,8 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ReadingsController < ActionController::API
|
class ReadingsController < ActionController::API
|
||||||
rescue_from ActiveRecord::RecordNotFound, with: :bad_request_error
|
# rescue_from ActiveRecord::RecordNotFound, with: :bad_request_error
|
||||||
rescue_from ActionController::ParameterMissing, with: :bad_request_error
|
# rescue_from ActionController::ParameterMissing, with: :bad_request_error
|
||||||
|
|
||||||
# @see {https://docutopia.tupale.co/sutty:nodemecu:api}
|
# @see {https://docutopia.tupale.co/sutty:nodemecu:api}
|
||||||
def create
|
def create
|
||||||
|
@ -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.find_or_initialize_by(local_id: a[:id], raspberry: raspberry)
|
arduino = reading.arduinos.find_or_initialize_by(local_id: a[:id])
|
||||||
|
|
||||||
a[:sensores].each do |s|
|
a[:sensores].each do |s|
|
||||||
arduino.sensors.build(sensor_params s)
|
arduino.sensors.build(sensor_params s)
|
||||||
|
|
Loading…
Reference in a new issue