crear las raspberries si no existen
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
f 2022-03-21 13:17:06 -03:00
parent 67c504f3e0
commit 97b455d413

View file

@ -49,8 +49,8 @@ class ReadingsController < ActionController::API
# número de serie apenas empiecen a actualizarse los nodemecu.
def raspberry
@raspberry ||= begin
r = Raspberry.find_by(serial_number: params[:serial_number])
r ||= Raspberry.find_by(name: params[:controller_id])
r = Raspberry.find_or_create_by(serial_number: params[:serial_number])
r ||= Raspberry.find_or_create_by(name: params[:controller_id])
r.tap do |r|
r.name = params[:controller_id]
r.serial_number = params[:serial_number]