Skip to content

Commit b958563

Browse files
committed
Overwrite PricesController#destroy to call #destroy
Price still responds to `#discard`, but we really want to call `#destroy`.
1 parent 4780302 commit b958563

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

backend/app/controllers/spree/admin/prices_controller.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,31 @@ def index
2323

2424
def edit
2525
end
26+
27+
def destroy
28+
invoke_callbacks(:destroy, :before)
29+
30+
if @object.destroy
31+
invoke_callbacks(:destroy, :after)
32+
flash[:success] = flash_message_for(@object, :successfully_removed)
33+
respond_with(@object) do |format|
34+
format.html { redirect_to location_after_destroy }
35+
format.js { render partial: "spree/admin/shared/destroy" }
36+
end
37+
else
38+
invoke_callbacks(:destroy, :fails)
39+
respond_with(@object) do |format|
40+
message = @object.errors.full_messages.to_sentence
41+
format.html do
42+
flash[:error] = message
43+
redirect_to location_after_destroy
44+
end
45+
format.js do
46+
render status: :unprocessable_entity, plain: message
47+
end
48+
end
49+
end
50+
end
2651
end
2752
end
2853
end

0 commit comments

Comments
 (0)