summaryrefslogtreecommitdiff
path: root/app/controllers/api/products_controller.rb
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-03-27 20:41:55 -0600
committerHombreLaser <sebastian-440@live.com>2023-03-27 20:41:55 -0600
commitefc5eb10894fc95487c55628b94024e97cd60139 (patch)
tree2e18f71385ce9cc62514ed39b9fbf6420e3ca198 /app/controllers/api/products_controller.rb
parent35ec25dcb3d57b17a3dc174503b7d20dd4c46e43 (diff)
Añade CardsController
Diffstat (limited to 'app/controllers/api/products_controller.rb')
-rw-r--r--app/controllers/api/products_controller.rb10
1 files changed, 3 insertions, 7 deletions
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