From 63eb60b9c16e392a704ff68cf8e2db45da9b0bad Mon Sep 17 00:00:00 2001 From: Coleman Date: Fri, 17 Oct 2008 04:06:40 -0500 Subject: [PATCH] rescue for when there are none --- app/controllers/photos.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/photos.rb b/app/controllers/photos.rb index 6f8c308..754c82b 100644 --- a/app/controllers/photos.rb +++ b/app/controllers/photos.rb @@ -93,8 +93,8 @@ class Photos < Application @photo_ids = Photo.find(:all, :select => 'id', :conditions => [ 'email_hash = ?', params[:id] ]).collect { |p| p.id } rescue [] @page = params[:page].to_i per_page = 4 - @photos = Photo.find :all, :conditions => "id IN (#{@photo_ids.join(',')})", :limit => per_page, :offset => (@page * per_page) - @votes = Vote.find :all, :conditions => "photo_id IN (#{@photo_ids.join(',')})" + @photos = Photo.find :all, :conditions => "id IN (#{@photo_ids.join(',')})", :limit => per_page, :offset => (@page * per_page) rescue [] + @votes = Vote.find :all, :conditions => "photo_id IN (#{@photo_ids.join(',')})" rescue [] @page_count = (@photo_ids.size.to_f / per_page.to_f).ceil if params[:id].to_s.empty? or @photo_ids.empty? or @votes.empty? redirect url(:action => :by_email)