Skip to content

Commit

Permalink
Rescue non-found shots
Browse files Browse the repository at this point in the history
  • Loading branch information
miharekar committed Nov 11, 2023
1 parent 1464783 commit fde1f32
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/controllers/shots_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ def show
return if current_user.nil?

@compare_shots = current_user.shots.where.not(id: @shot.id).by_start_time.limit(10).pluck(:id, :profile_title, :start_time)
rescue ActiveRecord::RecordNotFound
redirect_to :root
end

def compare
Expand Down Expand Up @@ -133,10 +131,14 @@ def remove_image

def load_shot
@shot = Shot.find(params[:id])
rescue ActiveRecord::RecordNotFound
redirect_to :root, alert: "Shot not found!"
end

def load_users_shot
@shot = current_user.shots.find(params[:id])
rescue ActiveRecord::RecordNotFound
redirect_to shots_path, alert: "Shot not found!"
end

def load_shots_with_pagy
Expand Down

0 comments on commit fde1f32

Please sign in to comment.