From efc5eb10894fc95487c55628b94024e97cd60139 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Mon, 27 Mar 2023 20:41:55 -0600 Subject: AƱade CardsController MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/products_controller.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'app/controllers/api/products_controller.rb') diff --git a/app/controllers/api/products_controller.rb b/app/controllers/api/products_controller.rb index 7856420..5fa7763 100644 --- a/app/controllers/api/products_controller.rb +++ b/app/controllers/api/products_controller.rb @@ -4,7 +4,7 @@ module Api # ProductsController class ProductsController < MasterController def show - render json: not_found_error_message, status: :not_found and return unless Product.exists?(public_id: params[:id]) + render status: :not_found and return unless Product.exists?(public_id: params[:id]) render json: serialized_object(params[:id]).serializable_hash, status: :ok end @@ -28,7 +28,7 @@ module Api def update @product = Product.find_by(public_id: params[:id]) - render json: not_found_error_message, status: :not_found and return if @product.nil? + render status: :not_found and return if @product.nil? if @product.update(object_params) render json: serialized_object(@product.public_id).serializable_hash, status: :ok @@ -40,7 +40,7 @@ module Api def destroy @product = Product.find_by(public_id: params[:id]) - render json: not_found_error_message, status: :not_found and return if @product.nil? + render status: :not_found and return if @product.nil? @product.destroy render status: :see_other @@ -72,9 +72,5 @@ module Api public_id = SecureRandom.hex(12) while Product.exists?(public_id:) permitted_params.merge(categories:, public_id:) end - - def not_found_error_message - { error_message: 'No existe el producto' } - end end end -- cgit v1.2.3