envolver todo en una transacción
This commit is contained in:
parent
cf4dfa3aad
commit
8de7a8a74c
1 changed files with 15 additions and 13 deletions
|
@ -6,6 +6,7 @@ class ReadingsController < ActionController::API
|
|||
|
||||
# @see {https://docutopia.tupale.co/sutty:nodemecu:api}
|
||||
def create
|
||||
Reading.transaction do
|
||||
reading = raspberry.readings.build reading_params
|
||||
reading.id = params[:transaction_uuid]
|
||||
# TODO: Verificar firma
|
||||
|
@ -20,11 +21,12 @@ class ReadingsController < ActionController::API
|
|||
end
|
||||
|
||||
if reading.save
|
||||
render plain: reading.uuid, status: :ok
|
||||
render plain: reading.id, status: :ok
|
||||
else
|
||||
head :bad_request
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
|
Loading…
Reference in a new issue