Commit 0f74d99a

mo khan <email@mokhan.ca>
2011-05-11 02:59:53
check if there are any creations before attempting to display one.
1 parent d71f996
Changed files (2)
app
app/views/creations/index.html.erb
@@ -1,9 +1,15 @@
 
 <div class="welcomeHolder">
   <div class="welcome">
+    <% if @creations.any? %>
     <a href="<%= url_for @creations[0] %>">
       <%= image_tag @creations[0].image_url.to_s, :width => 417, :height => 205, :class => 'photo' %>
     </a>
+    <% else %>
+    <a href="<%= url_for @creations[0] %>">
+      <%= image_tag "cakes/Camouflage_Truck.jpg", :width => 417, :height => 205, :class => 'photo' %>
+    </a>
+    <% end %>
     <h1>Browse All Creations</h1>
     <p><em>What time is it? Nana, nana, naaaaana caake time!</em></p>  
     <p>Check out our communities most recent cake work.</p>
app/views/home/index.html.erb
@@ -1,8 +1,14 @@
 <div class="welcomeHolder">
   <div class="welcome">
+    <% if @creations.any? %>
     <a href="<%= url_for @creations[0] %>">
       <%= image_tag @creations[0].image_url.to_s, :width => 417, :height => 205, :class => 'photo' %>
     </a>
+    <% else %>
+    <a href="<%= url_for @creations[0] %>">
+      <%= image_tag "cakes/Camouflage_Truck.jpg", :width => 417, :height => 205, :class => 'photo' %>
+    </a>
+    <% end %>
     <h1>Welcome to the CakeSide</h1>
     <p><em>An online community for cake artists, enthusiasists and eaters.</em></p>
     <p align="right">