Simple Controller/Routes Question

This is probably a very basic question, but what is the proper
controller & routing setup if I’m setting up a RoR site with static
pages, like:

http://mysite.com/about
http://mysite.com/services
http://mysite.com/contact

I want each of these pages to use a single template file that I can push
content to. It seems like overkill to create individual controllers for
about, services, and contact, so what is the best way to set this up?

You either configure routes mapping (routes.rb) and use just one
controller
and define in each action a diferent template with the render command or
you
create differnt controllers, which is much simpler.

It mainly depends on how you want to group things together.

Brandon S. wrote:

This is probably a very basic question, but what is the proper
controller & routing setup if I’m setting up a RoR site with static
pages, like:

http://mysite.com/about
http://mysite.com/services
http://mysite.com/contact

I want each of these pages to use a single template file that I can push
content to. It seems like overkill to create individual controllers for
about, services, and contact, so what is the best way to set this up?

What I’ve done is create a simple controller called “site” which will
group all my contact/about/privacy terms/etc pages together. Then I use
routes to direct “/about” to “/site/about”:

map.contact '/contact', :controller => 'site', :action => 'contact'
map.about '/about', :controller => 'site', :action => 'about'
map.terms '/terms', :controller => 'site', :action => 'terms'
map.privacy '/privacy', :controller => 'site', :action => 'privacy'

Jeff C.man

Jeff C.man wrote:

What I’ve done is create a simple controller called “site” which will
group all my contact/about/privacy terms/etc pages together. Then I use
routes to direct “/about” to “/site/about”:

map.contact ‘/contact’, :controller => ‘site’, :action => ‘contact’
map.about ‘/about’, :controller => ‘site’, :action => ‘about’
map.terms ‘/terms’, :controller => ‘site’, :action => ‘terms’
map.privacy ‘/privacy’, :controller => ‘site’, :action => ‘privacy’

Jeff C.man

Jeff… awesome! That sounds like a good solution. I’ll try it out.

Roberto,

Thanks for the info… I would like to have one design template and push
content from each page to the template, so it seems like the single
controller is the way to go… does anyone have other thoughts?

Brandon