Commit 9384e078

mo khan <mo@mokhan.ca>
2013-03-19 04:31:17
redirect to tags if category is not found
1 parent 3946998
Changed files (1)
app/controllers/categories_controller.rb
@@ -2,6 +2,10 @@ class CategoriesController < ApplicationController
   # GET /categories/fondant
   def show
     @category = Category.where(:slug => params[:id]).first
-    @creations = Creation.joins(:categories).where(:categories => {:slug => params[:id]}).page(params[:page]).per(12)
+    if @category
+      @creations = Creation.joins(:categories).where(:categories => {:slug => params[:id]}).page(params[:page]).per(12)
+    else
+      redirect_to "/tags/#{params[:id]}"
+    end
   end
 end