Navigation techniques, everyone?

I’m rewriting the code to my first app. I want to reuse a lot of it,
but tidy it up a lot. The first thing I will tackle is my nav-bar.
Throughout a user’s experience on my app, I want it to reload as little
as possible (I’ll have about 7 or 8 controllers with about 70 actions).

So, I’ve thought of a few ways of doing it, and was wondering if you
guys have any others!

  1. Make a controller for it, and have every other controller’s actions
    inserted (will this cause problems? will i be forced to use render
    components? i’ve heard they’re evil)

  2. Make it’s whole layout be a helper method in application_helper.rb,
    and the views can call it when they need it.

  3. Put it in my application.rhtml layout.

What do you guys think?

-Ben L.

On 7/18/06, Ben L. [email protected] wrote:

components? i’ve heard they’re evil)

  1. Make it’s whole layout be a helper method in application_helper.rb,
    and the views can call it when they need it.

  2. Put it in my application.rhtml layout.

What do you guys think?

-Ben L.

I’m not sure I really understand the goal. If it’s just a speed issue
couldn’t you just use partials and cache it with fragment caching? For
our project we just have a few partial views in views/shared which get
used by all the controllers and are easy to cache.

Or is the problem that the nav bar is cluttered?

-Chuck V.

On 7/18/06, Ben L. [email protected] wrote:

Well, Both I guess. I was mainly looking at clutter, though.

With your partials, did you put a copy of them in each controller?

My situation sounds a little bit different, we really only deal with
the controller level on the nav_bar so clutter isn’t an issue; mostly
we were worried about DRYness. But with a shared folder we didn’t have
to duplicate the file. The clutter issue was resolved with a little js
so when a top-level menu item is clicked the js rolls out the rest of
the menu. Not perfect for everybody though, I’m sure the blind people
in the crowd are pissed but it’s an intranet so they’ll never have to
deal with it.

render :partial => ‘shared/top_menu’, :layout => ‘whatever’

Again, the reasons are unclear, but when you have a / anywhere in a
:partial it assumes you mean app/views/:partial which is pretty handy.
Pop in a little caching and js and you have a pretty awesome little
menu system.

Well, Both I guess. I was mainly looking at clutter, though.

With your partials, did you put a copy of them in each controller?

-Ben L.

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