Skip to content

Commit dafb773

Browse files
committed
fix/Redirect snippet deletion from show page to snippets_path
1 parent f43343a commit dafb773

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

app/controllers/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class ApplicationController < ActionController::Base
33
serialization_scope :view_context
44
before_action :configure_permitted_parameters, if: :devise_controller?
55

6-
UNAUTHORIZED = 'You do not have access this page'.freeze
6+
UNAUTHORIZED = 'You do not have access to this page'.freeze
77

88
protected
99

app/controllers/snippets_controller.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,13 @@ def destroy
182182
flash[:alert] = 'Unable to delete snippet'
183183
end
184184

185-
redirect_to URI(request.referrer).path
185+
redirect_path = if URI(request.referrer).path == snippet_path(@snippet)
186+
snippets_path
187+
else
188+
URI(request.referrer).path
189+
end
190+
191+
redirect_to redirect_path
186192
end
187193

188194
format.json do

0 commit comments

Comments
 (0)