My thoughts on site navigation

Here’s a rough layout of what I think I can do to make one of those
nifty drop down menus while still restricting what certain roles can
see. What I want to do is create a data structure that will hold the
text of the menu item, the link to which it points, and an array of
strings representing the roles that can access the item. This structure
would also need to hold a set of child nodes.
Doing this, it’s just simple iteration and recursion (and checking of
the user’s list of roles, which I’m thinking of storing in session
information) to dump out the ul and li elements which will make up the
menu. Then I’ll use CSS to style it. This data structure would need to
be initialized during application start-up and maintained as long as the
site is running.

So, my questions are:

  1. Is this the right way to go about this?
  2. Would I put the code to do this in the application controller and use
    a global variable?
  3. This site isn’t likely to have to scale to multiple servers, so I
    feel pretty safe putting the list of roles in which a user is a member
    into a session variable when they are authenticated.
  4. What happens if I need to update the site navigation? Do I need to
    have some way to detect that the file has changed. If so, how and where
    do I go about it?

Thanks in advance,
William Gant

Get your own web address for just $1.99/1st yr. We’ll help. Yahoo! Small

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