Commit 543ab218

mo k <mo@mokhan.ca>
2012-09-20 12:48:39
filter tutorials by tag.
1 parent b5f3f4d
Changed files (2)
app
app/controllers/tutorials_controller.rb
@@ -2,7 +2,11 @@ class TutorialsController < ApplicationController
   before_filter :authenticate_user!, :except => [:show, :index]
 
   def index
-    @tutorials = Tutorial.all.reverse
+    if params[:tags] 
+      @tutorials = Tutorial.tagged_with([params[:tags]])
+    else
+      @tutorials = Tutorial.all.reverse
+    end
   end
 
   def show
app/views/tutorials/index.html.erb
@@ -17,10 +17,10 @@
         <div class="thumbnail">
           <img src="<%= tutorial.image_url %>" />
           <div class="caption">
-            <h3><%= tutorial.heading %> <small><%= tutorial.created_at.to_s :foomat %></small></h3>
+            <h3><a href="<%= tutorial.url %>" target="_blank"><%= tutorial.heading %></a> <small><%= tutorial.created_at.to_s :foomat %></small></h3>
             <p>
             <% tutorial.tags.each do |tag| -%>
-              <a href="tags/<%= tag.id %>"><span class="label"><%= tag.name %></span></a>
+              <a href="?tags=<%= tag.name %>"><span class="label"><%= tag.name %></span></a>
             <% end -%>
             </p>
             <p><%= tutorial.description %></p>