Forum: Ruby on Rails Simple Sidebar Solutions: How does yours work?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
61396c69040bbc56dbad1c5c71ac27d2?d=identicon&s=25 rhubarb (Guest)
on 2006-03-28 15:55
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.

<div id="sidebar">
<div id="controls" class="sidebar-node">
        <li><%= link_to "Refresh Pictures", { :action =>
'scan_directory'}, :confirm => "Are you sure?"%>
        <li><%= link_to "All Pictures", { :action => 'list' } %>
</div><!-- #sidebar -->

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 <li> 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.
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Kevin Olbrich (Guest)
on 2006-03-28 18:00
(Received via mailing list)
Components really aren't all that hard, but...

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

<div id="sidebar"> <%= @sidebar %> </div>

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

This topic is locked and can not be replied to.