I want to make a simple website with rails, but I'm confused about how
to setup my controllers. Here's what I want:
5 pages: Home, Products & Services, Press Center, White Papers & About
us
So, I'm confused about how to set this up. Should each page have it's
own controller, e.g.:
home_controller, products_controller, press_controller,
white_papers_controller and about_us_controller
Is this a wise design decision?
I would like to use a layout "template" for all the pages. How then,
if I'm using independent controllers for each page do I share a
layout?
All the rails site examples I've found are kinda non-standard sites
with only 1 real page, like a shopping cart, so I'm not sure how to
structure my rails app for a site with many pages.
Well, all of the pages are pretty much standard, read an object from
the database then databind the page. SO that would fit into your one
controller idea with many actions for each page.
I want to make a simple website with rails, but I'm confused about how
to setup my controllers. Here's what I want:
5 pages: Home, Products & Services, Press Center, White Papers & About
us
So, I'm confused about how to set this up. Should each page have it's
own controller, e.g.:
home_controller, products_controller, press_controller,
white_papers_controller and about_us_controller
Is this a wise design decision?
Can't tell, with the information given.
The very "general" rule is to have a controller per model, so that's a
good place to start. But it's not necessary to agonize over the
structure of your controllers. Rather than trying to envision how the
whole thing will look like when it's done, just implement a very small
part of it. Start with one controller. Then when you need to add
stuff, you have a choice: do I add an action to my current controller
or do I create a new controller? Well, make your best guess and see
how that goes. If it turns out to be problematic for whatever reason,
it's easy to back up and take the other direction.
Also, don't agonize over what the url's look like. You can use routes
to map any kind of urls to any kind of controller structure.
I would like to use a layout "template" for all the pages. How then,
if I'm using independent controllers for each page do I share a
layout?
By default, all controllers will use the layout in
app/views/layouts/application.rhtml. So put your template there and
you're done.
I want to make a simple website with rails, but I'm confused about how
to setup my controllers. Here's what I want:
5 pages: Home, Products & Services, Press Center, White Papers & About
us
So, I'm confused about how to set this up. Should each page have it's
own controller, e.g.:
home_controller, products_controller, press_controller,
white_papers_controller and about_us_controller
Is this a wise design decision?
Can't tell, with the information given.
The very "general" rule is to have a controller per model, so that's a
good place to start. But it's not necessary to agonize over the
structure of your controllers. Rather than trying to envision how the
whole thing will look like when it's done, just implement a very small
part of it. Start with one controller. Then when you need to add
stuff, you have a choice: do I add an action to my current controller
or do I create a new controller? Well, make your best guess and see
how that goes. If it turns out to be problematic for whatever reason,
it's easy to back up and take the other direction.
Also, don't agonize over what the url's look like. You can use routes
to map any kind of urls to any kind of controller structure.
I would like to use a layout "template" for all the pages. How then,
if I'm using independent controllers for each page do I share a
layout?
By default, all controllers will use the layout in
app/views/layouts/application.rhtml. So put your template there and
you're done.
I know this reply is quite far down in the thread but have you considered using a Content Management System like Radiant? Based on the scarce requirements in the OP's email, it would appear that if most of the pages are largely static (like a company website), Radiant would be quite good!