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}
|
# @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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue