Skip to content

Instantly share code, notes, and snippets.

@jdkealy
Created October 29, 2011 09:23
Show Gist options
  • Save jdkealy/1324267 to your computer and use it in GitHub Desktop.
Save jdkealy/1324267 to your computer and use it in GitHub Desktop.
#routes.rb
Rails.application.routes.draw do
match '/blog' => 'cms#blog'
match '/blog/:id' => 'cms#post'
match '/categories/:id' => 'cms#category'
match '/tags/:id' => 'cms#tag'
match '/:id' => 'cms#page'
end
#cms_controller.rb
class CmsController < ApplicationController
def post
@post = Post.find(params[:id])
respond_to do |format|
format.html # index.html.erb
end
end
def page
@page = Page.find(params[:id])
respond_to do |format|
format.html # index.html.erb
end
end
def category
@category = Category.find(params[:id])
respond_to do |format|
format.html # index.html.erb
end
end
def tag
@tag = Tag.find(params[:id])
respond_to do |format|
format.html # index.html.erb
end
end
def blog
@posts = Post.all
respond_to do |format|
format.html # index.html.erb
end
end
end
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment