Commit b3232104
Changed files (4)
app
controllers
views
creations
tags
config
app/controllers/categories_controller.rb
@@ -1,7 +1,7 @@
class CategoriesController < ApplicationController
# GET /categories/fondant
def show
- @category = Category.where(:slug => params[:id]).first
+ @category = Category.find_by_slug(params[:id])
if @category
@creations = Creation.includes(:user).joins(:categories).where(:categories => {:slug => params[:id]}).page(params[:page]).per(12)
else
app/views/creations/show.html.erb
@@ -31,9 +31,6 @@
<p>by <%= link_to @creation.user.name, profile_path(@creation.user) %></p>
<hr />
<span> <i class="icon-tags"></i> </span>
- <% @creation.categories.each do |category| %>
- <a href="/categories/<%= category.slug %>"><span class="label"><%= category.name %></span></a>
- <% end %>
<% @creation.tags.each do |tag| -%>
<a href="/tags/<%= tag.name %>"><span class="label"><%= tag.name %></span></a>
<% end -%>
config/routes.rb
@@ -9,24 +9,33 @@ Cake::Application.routes.draw do
match "about_us" => "home#about_us"
match "why_cakeside" => "home#why_cakeside"
- resources :tutorials
+ resources :tutorials do
+ get 'page/:page', :action => :index, :on => :collection
+ end
# /creations
resources :creations do
resources :photos, :only => [:index, :new, :create, :destroy]
resources :favorites, :only => [:index, :create]
resources :comments, :only => [:index, :new, :create]
+ get 'page/:page', :action => :index, :on => :collection
end
# /profiles
- resources :profiles, :only => [:index, :show]
+ resources :profiles, :only => [:index, :show] do
+ get 'page/:page', :action => :index, :on => :collection
+ end
match 'favorites' => 'profiles#favorites', :as => 'profiles_favorites', :method => 'GET'
# /categories
- resources :categories, :only => [:show]
+ resources :categories, :only => [:show] do
+ get 'page/:page', :action => :show, :on => :collection
+ end
# /tags
- resources :tags, :only => [:show]
+ resources :tags, :only => [:show] do
+ get 'page/:page', :action => :show
+ end
# /search
get "search/index"