Skip to content

Commit

Permalink
Merge pull request #141 from openSUSE/500-error
Browse files Browse the repository at this point in the history
Prevent missing pastes triggering error 500
  • Loading branch information
hellcp authored Oct 24, 2023
2 parents 8c8627a + 0239174 commit 8710923
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/controllers/pastes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def index
end
end

def show; end
def show
authorize @paste
end

def new
@paste = authorize Paste.new
Expand All @@ -39,6 +41,8 @@ def create
end

def destroy
authorize @paste

@paste.destroy

respond_to do |format|
Expand All @@ -50,7 +54,7 @@ def destroy
private

def set_paste
@paste = authorize Paste.find_by(permalink: params[:permalink])
@paste = Paste.find_by(permalink: params[:permalink])

redirect_to pastes_url, alert: t(:paste_not_found) unless @paste
end
Expand Down

0 comments on commit 8710923

Please sign in to comment.