From 489edd2d2caa09986bcf72b9add839b66895e20b Mon Sep 17 00:00:00 2001 From: Dan Barber Date: Thu, 6 Mar 2014 10:43:49 +0000 Subject: [PATCH] Fix home page error with no photos. --- app/controllers/home_controller.rb | 2 +- app/views/home/index.html.erb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 0ce5713..07e608b 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,5 +1,5 @@ class HomeController < ApplicationController def index - @photo = Photo.featured.order('RANDOM()').first + @photos = Photo.featured.order('RANDOM()').limit(1) end end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 7489207..6be8d40 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,12 +1,12 @@ -<%= render 'shared/photo_styles', photos: [@photo], size: 17 %> +<%= render 'shared/photo_styles', photos: @photos, size: 17 %> <% content_for :navigation do %> <%= render 'shared/main_nav' %> <% end %> -<% if @photo %> -
- <%= link_to_photo @photo %> +<% if @photos.first.present? %> +
+ <%= link_to_photo @photos.first %>
<% end %>