Commit 318373e8

mo khan <mo@mokhan.ca>
2013-06-22 14:47:12
add index action to tutorial tags
1 parent cc85304
Changed files (3)
app
controllers
views
tutorial_tags
config
app/controllers/tutorial_tags_controller.rb
@@ -1,4 +1,8 @@
 class TutorialTagsController < ApplicationController
+  def index
+    @tags = Tutorial.tag_counts_on(:tags)
+  end
+
   def show
     @tag = params[:id].downcase.gsub(/ /, '-')
     @total_tutorials = Tutorial.tagged_with(@tag).count
app/views/tutorial_tags/index.html.erb
@@ -0,0 +1,8 @@
+<% provide(:title, "Tag, you're it".html_safe) -%>
+<div class="row">
+  <div class="span12">
+    <% tag_cloud(@tags, %w(btn-mini btn-small btn-large)) do |tag, css_class| %>
+      <%= link_to "#{tag.name} x #{tag.count}", { :action => :show, :id => tag.name }, :class => "#{css_class} btn" %>
+  <% end %>
+  </div>
+</div>
config/routes.rb
@@ -6,7 +6,7 @@ Cake::Application.routes.draw do
   resources :tutorials do
     get 'page/:page', :action => :index, :on => :collection
   end
-  resources :tutorial_tags, :only => [:show], :path => :tt
+  resources :tutorial_tags, :only => [:index, :show], :path => :tt
 
   # /creations
   resources :creations do