Topic: display controllers dynamically as navigation links

Alright this may be a stupid question but I am curious if there is a way to display links to controllers dynamically..

for example..

you have 5 controllers:  index, tutorials, reviews, forums, and admin.

is there a way that you could define in the controllers whether to display in the navigation.  for example you would tell all controllers to display in the navigation except the admin controller.

so in the view you would put a little snippet of code that would make links to all of the controllers(except the admin controller).

i understand that this is confusing, so if you don't get where i'm coming from that's fine heh.

Re: display controllers dynamically as navigation links

I think what you're looking for is layouts.

Add a file here: "views/layouts/application.rhtml". This will then act as the layout for every controller. You can put content in here like this:

<html>
  <head><title>My Site</title></head>
  <body>
    # put navigation here....
    <%= yield %> # the template for each action will be rendered here.
  </body>
</head>

If you rename "application.rhtml" to the name of your controller it will use that layout for only that specific controller.

Does that answer your question?

Railscasts - Free Ruby on Rails Screencasts

Re: display controllers dynamically as navigation links

no but i think what i'm looking for doesn't exist.  that does help though. 

one question: is it more commonly accepted to use "yield" or "@content_for_layout" ?

Re: display controllers dynamically as navigation links

steve wrote:

one question: is it more commonly accepted to use "yield" or "@content_for_layout" ?

Yes, using @content_for_layout is being depricated.

Railscasts - Free Ruby on Rails Screencasts