Good question. I think there are a lot of ways to get the job done here.
One method I've used in the past is to generate a "pages" controller (or
'static', or whatever you want to call it) and then create named routes
for my individual pages. So for your situation I would put this in my
map.root :controller => 'pages', :action => 'home' (map.root creates the
route for '/')
map.news 'news', :controller => 'pages', :action => 'news'
map.links 'links', :controller => 'pages', :action => 'links'
map.links 'about-us', :controller => 'pages', :action => 'about_us'
The only thing you have to do is make sure you have a home.html.erb,
news.html.erb, and links.html.erb in the app/views/pages directory.
There are many other ways to solve this problem, and I would also be
curious to see what others recommend.
Josh Susser recently blogged about this here
http://blog.hasmanythrough.com/2008/4/2/simple-pages. That's another way
of doing it, although I prefer using named routes generally because I
like having more control over the way my url looks (I can tell my URL to
say 'about-us' instead of 'about_us'), but either way is completely
legit I think.
For a more advanced solution to this problem, also check out Ryan Bates
Railscast on dynamically generating named routes. It's more of an a cool
example of the dynamic nature of Ruby (generating a method at run-time
== very cool) but it may be what you're looking for.
Hope all this helped and I'll check back to see what other say in this
thread. I know there are a lot of ways to skin a cat here.
-- Josh N. Abbott
P.S. Cool tip: Next time you're in console and you've just added a named
route or resource to your routes.rb and you want to see if it works
simply type app.get '/about-us' (or whatever your relative path would
look like. You'll get back a status code telling you if it was found
(200) or not (404). You don't even have to have the controller. It'll
run straight off routes.rb.
Rick Schumeyer wrote: