Simple Sidebar Solutions: How does yours work?

I’m working on a simple photo gallery app for personal use and I want to
generalize the sidebar such that in any page (controller or view, I’m
not sure which) I can dynamically add either

  1. links to a given sidebar
  2. or an entire sidebar.

I know that typo does this, and I’ve looked the code. I think it’s too
complex a solution for my simple site. I’d like to avoid using
components, and make do with a bit of code in the layout and maybe a
partial and a helper or something.

Here’s the code that’s in my sidebar now.


  • <%= link_to "Refresh Pictures", { :action => 'scan_directory'}, :confirm => "Are you sure?"%>
  • <%= link_to "All Pictures", { :action => 'list' } %>

Now lets say I want to take out those 2 links and specifying them from,
say, my list.rhtml page. How would I go about it?

I was thinking of creating a literal array of links, then using a
partial that loops over the array with an

  • for each one.
    Does that sound easiest?

    Whats the best way to put the link info in an array? Could I make an
    array of the html result of the link_to calls themselves?
    Or maybe an array of literal hashes of the arguments to link_to?
    Or do I need to make my own structure?

    How do other apps, outside of typo, deal with dynamic sidebars? Or
    toolbars for that matter - it’s more a toolbar than a sidebar really.

  • Components really aren’t all that hard, but…

    You could put a instance variable in the correct spot like…

    <%= @sidebar %>

    And then have each controller set the varible @sidebar in a


    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