From 332feb3066c7e0fd497311424ffe12c557f49fdd Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Sun, 21 May 2023 10:00:50 -0600 Subject: Corrige errores en AddressesController --- app/controllers/api/addresses_controller.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'app/controllers/api') diff --git a/app/controllers/api/addresses_controller.rb b/app/controllers/api/addresses_controller.rb index dbd77d9..834f721 100644 --- a/app/controllers/api/addresses_controller.rb +++ b/app/controllers/api/addresses_controller.rb @@ -9,6 +9,16 @@ module Api render json: serialized_collection.serializable_hash, status: :ok end + def show + @address = current_user_account.addresses.find_by(id: params[:id]) + + if @address.nil? + render status: :not_found + else + render json: serialized_object.serializable_hash, status: :ok + end + end + def create @service = Addresses::CreateAddressService.new(current_user_account, service_params) @@ -40,7 +50,8 @@ module Api render json: serialized_object.serializable_hash, status: :ok end rescue ActiveRecord::RecordNotUnique - render json: { error_message: 'Ya cuenta con esta dirección' }, status: :unprocessable_entity + @address = current_user_account.addresses.find(params[:id]) + render json: serialized_object.serializable_hash, status: :ok end end -- cgit v1.2.3