Skip to content

Commit

Permalink
don't redirect back to deleted files or models
Browse files Browse the repository at this point in the history
  • Loading branch information
Floppy committed Mar 4, 2024
1 parent aa87b6c commit cf22ebf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/controllers/model_files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ def bulk_update
def destroy
authorize @file
@file.delete_from_disk_and_destroy
redirect_back_or_to library_model_path(@library, @model), notice: t(".success")
if URI.parse(request.referer).path == library_model_model_file_path(@library, @model, @file)
# If we're coming from the file page itself, we can't go back there
redirect_to library_model_path(@library, @model), notice: t(".success")
else
redirect_back_or_to library_model_path(@library, @model), notice: t(".success")
end
end

private
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/models_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ def bulk_update
def destroy
authorize @model
@model.delete_from_disk_and_destroy
redirect_back_or_to library_path(@library), notice: t(".success")
if URI.parse(request.referer).path == library_model_path(@library, @model)
# If we're coming from the model page itself, we can't go back there
redirect_to library_path(@library), notice: t(".success")
else
redirect_back_or_to library_path(@library), notice: t(".success")
end
end

private
Expand Down

0 comments on commit cf22ebf

Please sign in to comment.