Skip to content

Commit

Permalink
included LogDestroyPerformer on product model
Browse files Browse the repository at this point in the history
  • Loading branch information
abdellani committed May 17, 2024
1 parent 40b2361 commit 8ccb59a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/api/v0/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def destroy
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
Expand Down
1 change: 1 addition & 0 deletions app/models/concerns/log_destroy_performer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module LogDestroyPerformer
extend ActiveSupport::Concern
included do
attr_accessor :destroyed_by

after_destroy :log_who_destroyed

def log_who_destroyed
Expand Down
1 change: 1 addition & 0 deletions app/models/spree/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
module Spree
class Product < ApplicationRecord
include ProductStock
include LogDestroyPerformer

self.belongs_to_required_by_default = false

Expand Down

0 comments on commit 8ccb59a

Please sign in to comment.