1
0
mirror of https://github.com/danbee/danbarberphoto synced 2025-03-04 08:49:07 +00:00

Fix home page error with no photos.

This commit is contained in:
Dan Barber 2014-03-06 10:43:49 +00:00
parent b39549e348
commit 489edd2d2c
2 changed files with 5 additions and 5 deletions

View File

@ -1,5 +1,5 @@
class HomeController < ApplicationController
def index
@photo = Photo.featured.order('RANDOM()').first
@photos = Photo.featured.order('RANDOM()').limit(1)
end
end

View File

@ -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 %>
<div class="sg-17 photo" id="<%= @photo.name.parameterize %>">
<%= link_to_photo @photo %>
<% if @photos.first.present? %>
<div class="sg-17 photo" id="<%= @photos.first.name.parameterize %>">
<%= link_to_photo @photos.first %>
</div>
<% end %>