included LogDestroyPerformer on product model

This commit is contained in:
Mohamed ABDELLANI
2024-05-09 14:39:36 +01:00
parent 40b2361572
commit 8ccb59a9ab
3 changed files with 3 additions and 0 deletions

View File

@@ -42,6 +42,7 @@ module Api
authorize! :delete, Spree::Product
@product = product_finder.find_product
authorize! :delete, @product
@product.destroyed_by = current_api_user
@product.destroy
render json: @product, serializer: Api::Admin::ProductSerializer, status: :no_content
end

View File

@@ -6,6 +6,7 @@ module LogDestroyPerformer
extend ActiveSupport::Concern
included do
attr_accessor :destroyed_by
after_destroy :log_who_destroyed
def log_who_destroyed

View File

@@ -23,6 +23,7 @@ require 'open_food_network/property_merge'
module Spree
class Product < ApplicationRecord
include ProductStock
include LogDestroyPerformer
self.belongs_to_required_by_default = false