From c016805af84e8a6d36bddb46fae7604b5ee02357 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 15 Oct 2017 13:40:31 -0400 Subject: Actually fixed index page when there's no Pokémon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pokeviewer/pokemon_controller.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/controllers/pokeviewer/pokemon_controller.rb b/app/controllers/pokeviewer/pokemon_controller.rb index 4b49184..49a743c 100644 --- a/app/controllers/pokeviewer/pokemon_controller.rb +++ b/app/controllers/pokeviewer/pokemon_controller.rb @@ -21,10 +21,14 @@ module Pokeviewer end end - if pokemon.peek and pokemon.peek.first == -1 - @unaccounted = pokemon.next.second - else - @unaccounted = [] + @unaccounted = [] + + begin + if pokemon.peek.first == -1 + @unaccounted = pokemon.next.second + end + rescue StopIteration + # There are no Pokémon, but that's fine. end @trainers = Trainer.order(id: :asc).all.map do |trainer| -- cgit 1.4.1