One or Multiple Controllers

I’m working on a small project (5 major pages, 1 with 4 linked off, 1
with 3
linked off) and I was going to just do it all in flat html files with
dreamweaver templates (yeah, I was being kinda lazy). I got the sigle
page
sections done and find out, it would really be nice to do this page in
with
a database (list of new products). So I thought, hey maybe this is a
good
use for rails (don’t laugh! I’m desperate for an excuse).

After about 1 hour I had my dreamweaver pages put into a rails project
with the
layout.rhtml and the contents broken out into template files. I was
nearly
giggling with joy.

I made a Page controller with these actions: index, about, contact,
products
and information. The Page template has a sidebar menu, @submenu to
render as partial template

Information needs a sidebar menu, so in the method information
specified the name of the template to render :partial=>@submenu

Also in the Page controller I had methods information_safety,
information_fundraising, and information_faq … each setting
@submenu to “info_menu”

Then I come to the product section, which has 4 sections and I did the
same
thing. It worked.

(so far no database interation)

Then I thought, maybe the better design was to create a Product
controller.
So I did. I set the submenu template name in the initialize method, and
told
it to use layout “Page” I tweaked the link in the layout/page.rhtml to
call
the Product controller. It worked.

Which is the better way or are both ways stupid and you have a better
one?
:slight_smile:


http://PhpGirl.blogger.com