---
title: "#117 Semi-Static Pages"
author: "CaiDeHen"
date: "2008-12-12T14:20:43Z"
tags: []
slug: "117-semi-static-pages"
draft: false
lastmod: "2008-12-12T14:20:43Z"
id: 291992
url: "https://caidehen.iteye.com/blog/291992"
---

Static pages can sometimes be a little awkward to add to a Rails app. See a couple different solutions to this problem in this episode.

```java
# pages_controller.rb
def show
  if params[:permalink]
    @page = Page.find_by_permalink(params[:permalink])
    raise ActiveRecord::RecordNotFound, "Page not found" if @page.nil?
  else
    @page = Page.find(params[:id])
  end
end

# routes.rb

map.static 'static/:permalink', :controller => 'pages', :action => 'show'

# or 

map.with_options :controller => 'info' do |info|
  info.about 'about', :action => 'about'
  info.contact 'contact', :action => 'contact'
  info.privacy 'privacy', :action => 'privacy'
end

<%= simple_format @page.content%>
or
<%= textilize @page.content %>
or
<%= RedCloth.new(@page.content).to_html %>
```