Commit 868ff7dd

mo khan <mo@mokhan.ca>
2013-06-16 16:49:39
update tags controller to just display the creations tagged with a tag and add a link to the tutorials that match the same tag
1 parent eae18d7
Changed files (2)
app
app/controllers/tags_controller.rb
@@ -1,7 +1,8 @@
 class TagsController < ApplicationController
   def show
     @tag = params[:id]
-    @tutorials = Tutorial.tagged_with([@tag])
-    @creations = Creation.includes(:user).tagged_with([@tag])
+    @total_tutorials = Tutorial.tagged_with(@tag).count
+    @total_creations = Creation.tagged_with(@tag).count
+    @creations = Creation.includes(:user).tagged_with([@tag]).page(params[:page]).per(15)
   end
 end
app/views/tags/show.html.erb
@@ -10,24 +10,14 @@
 </script>
 <% end -%>
 <% content_for :page_header do -%>
-  <h1>Tagged <em><%= @tag %></em></h1>
-  <h2><%= @creations.count %> creations and <%= @tutorials.count %> tutorials</h2>
+  <h1><%= @total_creations %> creations tagged <em><%= @tag %></em></h1>
 <% end -%>
+<div class="row">
+  <p class="pull-right"><a href="/tutorials?tag=<%= @tag %>"><%= @total_tutorials %> tutorials</a> &raquo;</p>
+</div>
 <div id="tutorials-div" class="row">
   <div class="span12">
     <ul class="thumbnails">
-      <% @tutorials.each do |tutorial| %>
-      <div class="span4">
-        <div class="thumbnail">
-          <a href="<%= url_for tutorial %>"><img src="<%= tutorial.image_url %>" /></a>
-          <div class="caption">
-            <h3><a href="<%= tutorial.url %>" target="_blank"><%= tutorial.heading %></a></h3>
-            <p><%= tutorial.description %></p>
-            <p><a class="btn" href="<%= url_for tutorial %>">View</a></p>
-          </div>
-        </div>
-      </div>
-    <% end %>
     <% @creations.each do |creation| %>
       <div class="span4">
         <div class="thumbnail">
@@ -43,3 +33,6 @@
     </ul>
   </div>
 </div>
+<div class="row">
+  <div class="span12"> <%= paginate @creations %> </div>
+</div>