summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-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