How to create subpages

What I am trying to do is create subpages within the main page.

So if the top navigation is

I would want a sub navigation under the pages like so;

----- History
www.example.com/about/history

----- Locations
www.example.com/about/locations

----- Careers
www.example.com/about/careers

----- Products
www.example.com/support/products

----- Forum
www.example.com/support/forum

Would I need to create a new controller for each page category? (i.e.
home,
about, contact, support). And then add the pages within each respective
category.

The big problem I am having currently is routing the pages.

So I currently have the top level navigation all done under 1 controller
(static_pages_controller.rb) & the routes.rb (match ‘/about’, to:
‘static_pages#about’).

So I am trying to figure out how I would add the subpages for about
(history, location, careers) so they the url
www.example.com/about/history
etc.

I’m sure there is an easy way to do this, but I can’t seem to figure it
out! Any help would be much appreciated!!

On Thu, Aug 16, 2012 at 3:27 PM, mack3000 [email protected]
wrote:

So if the top navigation is

The immediately obvious ways that leap to my mind are either that, or
manual routing to different controllers. They should all be pretty
trivial boilerplate, though, so it shouldn’t be too hard. I wouldn’t
be surprised if there is (or someone could whip up) a gem to make this
even easier…

I currently have the top level navigation all done under 1 controller
(static_pages_controller.rb) & the routes.rb (match ‘/about’, to:
‘static_pages#about’).

So I am trying to figure out how I would add the subpages for about
(history, location, careers) so they the url www.example.com/about/history
etc.

Without a lot of manual routing, off the top of my head, I’d say:

  • Make each top-level page its own controller, including an index action
  • Make each sub-page a new action within that controller

So for instance you’d have an “about” controller, with actions
including index (for /about), history (for /about/history), etc., and
a “support” controller, with actions including index (for /support),
products (for /support/products), and so on.

Or you could put them all in one controller, with more explicit manual
routing in routes.rb for the index actions.

-Dave


Dave A., Available Secret-Cleared Ruby/Rails Freelancer
(VA/DC/Remote);
see www.DaveAronson.com, www.Codosaur.us, and www.Dare2XL.com for more
info.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs