envolver todo en una transacción

This commit is contained in:
f 2022-03-03 14:14:22 -03:00
parent cf4dfa3aad
commit 8de7a8a74c

View file

@ -6,6 +6,7 @@ class ReadingsController < ActionController::API
# @see {https://docutopia.tupale.co/sutty:nodemecu:api} # @see {https://docutopia.tupale.co/sutty:nodemecu:api}
def create def create
Reading.transaction do
reading = raspberry.readings.build reading_params reading = raspberry.readings.build reading_params
reading.id = params[:transaction_uuid] reading.id = params[:transaction_uuid]
# TODO: Verificar firma # TODO: Verificar firma
@ -20,11 +21,12 @@ class ReadingsController < ActionController::API
end end
if reading.save if reading.save
render plain: reading.uuid, status: :ok render plain: reading.id, status: :ok
else else
head :bad_request head :bad_request
end end
end end
end
private private