Created
June 19, 2016 13:27
-
-
Save senhorinha/836653c6e72794f4000ba6cefebb925a to your computer and use it in GitHub Desktop.
O que tu prefere
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def register_owner | |
uuid = qr_code_params[:uuid] | |
qr_code = QrCode.find_by(uuid: uuid) | |
if(qr_code) | |
if(qr_code.user) | |
render json: QrCodeAlreadyHasAnOwnerError.new(uuid), status: :conflict | |
else | |
@current_user.qr_codes << qr_code | |
render json: qr_code, status: :created | |
end | |
else | |
render json: QrCodeNotFoundError.new(uuid), status: :not_found | |
end | |
end | |
def register_owner | |
uuid = qr_code_params[:uuid] | |
qr_code = QrCode.find_by(uuid: uuid) | |
return json: QrCodeNotFoundError.new(uuid), status: :not_found unless qr_code | |
return json: QrCodeAlreadyHasAnOwnerError.new(uuid), status: :conflict unless qr_code.user | |
@current_user.qr_codes << qr_code | |
render json: qr_code, status: :created | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👇