summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-04-06 11:04:41 -0600
committerHombreLaser <sebastian-440@live.com>2023-04-06 11:04:41 -0600
commitef0bd5e3ebd3822eca1aa12fb9e347ad397a295b (patch)
treea8f29f59fe879df2b5b24773131f6575c076a84b /app
parent111e93744aceb8a61c06dfa4d2d843544b7b1078 (diff)
Añadida creación de carrito a la hora de crearusuario
Diffstat (limited to 'app')
-rw-r--r--app/controllers/api/user_accounts_controller.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/controllers/api/user_accounts_controller.rb b/app/controllers/api/user_accounts_controller.rb
index 6404dee..da18448 100644
--- a/app/controllers/api/user_accounts_controller.rb
+++ b/app/controllers/api/user_accounts_controller.rb
@@ -12,7 +12,11 @@ module Api
def create
@user_account = UserAccount.new(permitted_params.merge(role: 'regular'))
- render json: generate_token, status: :ok and return if @user_account.save
+ if @user_account.save
+ render json: generate_token, status: :ok
+ @user_account.update(cart_id: Cart.create(user_account_id: @user_account.id).id)
+ return
+ end
render json: { errors: @user_account.errors.as_json }, status: :unprocessable_entity
end