Commit 38bc7c67

mo khan <mo@mokhan.ca>
2014-08-24 20:41:10
update each photo link to use the existing creations show page and just swap out the iamge.
1 parent 666639e
Changed files (2)
app
controllers
views
creations
app/controllers/creations_controller.rb
@@ -5,5 +5,10 @@ class CreationsController < ApplicationController
 
   def show
     @creation = FindCreationQuery.new.fetch(params[:id])
+    if params[:photo_id].present?
+      @primary_image = @creation.photos.find(params[:photo_id])
+    else
+      @primary_image = @creation.primary_image
+    end
   end
 end
app/views/creations/show.html.erb
@@ -2,7 +2,7 @@
 <% provide(:description, "#{@creation.story}") -%>
 <div class="row-fluid">
   <div class="span6">
-    <img class="thumbnail" src="<%= @creation.primary_image.url_for(:large) %>" alt="<%= @creation.name %>" />
+    <img class="thumbnail" src="<%= @primary_image.url_for(:large) %>" alt="<%= @creation.name %>" />
   </div>
   <div class="span6">
     <h1><%= link_to @creation.name, creation_path(@creation) %></h1>
@@ -42,14 +42,11 @@
 
 <% if @creation.photos_count > 1 %>
   <div class="row-fluid">
-    <div class="span12">
-      <%= link_to "View #{pluralize(@creation.photos_count, "photo")} &raquo;".html_safe, creation_photos_path(@creation) %>
-    </div>
     <div class="span12">
       <ul class="thumbnails">
       <% @creation.photos.each do |photo| %>
         <li class="span2">
-          <%= link_to creation_photo_path(@creation, photo) do %>
+          <%= link_to creation_path(@creation, photo_id: photo.id) do %>
             <%= image_tag(photo.url_for(:thumb), :class => "thumbnail") %>
           <% end %>
         </li>