Commit 32d83eda

mo k <mo@mokhan.ca>
2011-08-08 02:47:04
add slug to category.
1 parent a4cc155
app/controllers/search_controller.rb
@@ -3,4 +3,9 @@ class SearchController < ApplicationController
     @creations = Creation.search(params[:q], :include => :user, :match_mode => :extended, :star => true).page(params[:page]).per(6)
     @search = params[:q]
   end
+
+  def tags
+    @creations = Category.where(:slug => params[:id]).first.posts
+    render 'home/index'
+  end
 end
db/migrate/20110808024353_add_slug_to_categories.rb
@@ -0,0 +1,9 @@
+class AddSlugToCategories < ActiveRecord::Migration
+  def self.up
+    add_column :categories, :slug, :string
+  end
+
+  def self.down
+    remove_column :categories, :slug
+  end
+end
db/schema.rb
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version => 20110803021631) do
+ActiveRecord::Schema.define(:version => 20110808024353) do
 
   create_table "authentications", :force => true do |t|
     t.integer  "user_id"
@@ -24,6 +24,7 @@ ActiveRecord::Schema.define(:version => 20110803021631) do
     t.string   "name"
     t.datetime "created_at"
     t.datetime "updated_at"
+    t.string   "slug"
   end
 
   create_table "creations", :force => true do |t|
db/seeds.rb
@@ -5,14 +5,14 @@
 #
 #   cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
 #   Mayor.create(:name => 'Daley', :city => cities.first)
-Category.create(:name => 'Fondant')
-Category.create(:name => 'Butter Cream')
-Category.create(:name => 'Cup Cake')
-Category.create(:name => '3 Tier')
-Category.create(:name => '3D')
-Category.create(:name => 'Birthday')
-Category.create(:name => 'Wedding')
-Category.create(:name => 'Holiday')
-Category.create(:name => 'Theme')
-Category.create(:name => 'Anniversary')
-Category.create(:name => 'Baby Shower')
+Category.create(:name => 'Fondant', :slug => 'fondant')
+Category.create(:name => 'Butter Cream', :slug => 'butter-cream')
+Category.create(:name => 'Cup Cake', :slug => 'cup-cake')
+Category.create(:name => '3 Tier', :slug => '3-tier')
+Category.create(:name => '3D', :slug => '3d')
+Category.create(:name => 'Birthday', :slug => 'birthday')
+Category.create(:name => 'Wedding', :slug => 'wedding')
+Category.create(:name => 'Holiday', :slug => 'holiday')
+Category.create(:name => 'Theme', :slug => 'theme')
+Category.create(:name => 'Anniversary', :slug => 'anniversary')
+Category.create(:name => 'Baby Shower', :slug => 'baby-shower')
Gemfile.lock
@@ -63,7 +63,7 @@ GEM
       abstract (>= 1.0.0)
     eventmachine (0.12.10)
     excon (0.6.5)
-    factory_girl (2.0.2)
+    factory_girl (2.0.3)
     factory_girl_rails (1.1.0)
       factory_girl (~> 2.0.0)
       railties (>= 3.0.0)