NoMethodError in PhotosController#fresh

undefined method `created_at' for nil:NilClass

Extracted source (around line #139):
137
138
139
140
141
142
          
if params[:page].to_i > 1
cur_page_first_photo_day = @photos.first.created_at.to_date
photo_of_current_page = BestPhotoOfTheDay.where('day >= ?', cur_page_first_photo_day)
.first

Rails.root: /home/photobazaar/public_html

Application Trace | Framework Trace | Full Trace
app/controllers/photos_controller.rb:139:in `fresh'

Request

Parameters:

{"page"=>"2"}

Response

Headers:

None