Layouts, Searching/Sorting

Two questions for you all…

  1. I have an admin section to a site I’m building. Here’s the pertinent
    bit of the layout that all controllers are using:
<%= @content_for_layout %>

I’m using @content_for_layout to display various controller actions such
as new, edit, list etc. My problem is that for each controller I want a
specific chunk of content to show up in the sidebar. How can I
accomplish this without altering the layout to look something like this:

<%= @content_for_layout %>
<% if @controller.controller_name == 'news' %><%= render(:partial => "news_sidebar") %><% end %> <% if @controller.controller_name == 'users' %><%= render(:partial => "users_sidebar") %><% end %> <% if @controller.controller_name == 'links' %><%= render(:partial => "links_sidebar") %><% end %>

…There has to be a much more DRY way of doing that. Perhaps a helper
that takes the controller name as an argument? Other suggestions?

  1. I’m used to building searches and sorting mechanisms with PHP that
    analyze a $_GET request and display data based on those parametrs. URLs
    end up looking like:
    http://example.com/search.php&order=desc&category=foo&author=fred
    I have no idea how to build something simple like this with Rails – can
    someone provide some code for me to look at that does just this? I’m
    very much a learn by seeing kind of guy and would greatly appreciate it.

Thanks.