DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
About Controller
This controller will load the appropriate template if it exists, or display a 404 page if not.
class AboutController < ApplicationController
def index
unless @params["id"].nil?
if File.exists? "app/views/about/#{@params["id"]}.rhtml"
render(:template => "about/#{params["id"]}", :layout => true)
else
render(:template => "about/404", :status => 404, :layout => true)
end
else
render(:template => "about/index", :layout => true)
end
end
end






Comments
Snippets Manager replied on Mon, 2012/05/07 - 2:14pm
map.connect 'about/:id', :controller => "about", :action => "index", :id => "index"