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 class HomeController < ApplicationController
def index def index
@photo = Photo.featured.order('RANDOM()').first @photos = Photo.featured.order('RANDOM()').limit(1)
end end
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 %> <% content_for :navigation do %>
<%= render 'shared/main_nav' %> <%= render 'shared/main_nav' %>
<% end %> <% end %>
<% if @photo %> <% if @photos.first.present? %>
<div class="sg-17 photo" id="<%= @photo.name.parameterize %>"> <div class="sg-17 photo" id="<%= @photos.first.name.parameterize %>">
<%= link_to_photo @photo %> <%= link_to_photo @photos.first %>
</div> </div>
<% end %> <% end %>