| Class | PagesController |
| In: |
app/controllers/pages_controller.rb
|
| Parent: | ApplicationController |
Thinking we have a catch-all controller that uses render inline, but could use a template handler with a comple method that queries DB? Template-finding seems to assume a file, though
# File app/controllers/pages_controller.rb, line 8
8: def show
9: if params[:path]
10: path_params = params[:path].dup
11: last_path = path_params.pop
12: if last_path
13: last_path.gsub!(/.html$/, "")
14: if last_path && last_path != "index"
15: path_params << last_path
16: end
17: end
18: path = path_params.join("/")
19: else
20: path = ""
21: end
22:
23: @page = Page.find_by_path(path)
24:
25: # Seems to be the best way to trigger a conventional Rails 404
26: raise ActiveRecord::RecordNotFound.new("No page for /#{path}") unless @page
27:
28: render(:inline => @page.body, :layout => "application")
29: end