rescue for when there are none

master
Coleman 2008-10-17 04:06:40 -05:00
parent c872dd9527
commit 63eb60b9c1
1 changed files with 2 additions and 2 deletions

View File

@ -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)