From ef0bd5e3ebd3822eca1aa12fb9e347ad397a295b Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Thu, 6 Apr 2023 11:04:41 -0600 Subject: Añadida creación de carrito a la hora de crearusuario MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/user_accounts_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/controllers') 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 -- cgit v1.2.3