Skip to content

laying out sections using content_for

For the new style changes for confabulus, I made use of the content_for capabilities in rails. The currently has two sections, main and sidebar. content_for makes implementing this quite easy. In your layout file (example application.html.erb under app/views/layouts), you use a <%= yield :sectionname %> to place each of the sctions. Here I used <%= yield :sidebar %> to include my sidebar section. :sidebar is just the name I chose for the section.

<div class="right" id="main_right">
<div id="sidebar">
<%= yield :sidebar%>

Then in the view for the page, you need to define the content for each section, for sidebar I have:

<% content_for :sidebar do %>
<h2>Please Login</h2>
<div class="content">
... full view code omitted ...
<% end %>

So my views are of the form of:

<% content_for :sidebar do %>
... sidebar content goes here ...
<% end %>
<% content_for :main do %>
... main content goes here ...
<% end %>

You can do this for an arbitrary number of sections.
One thing to note is that if you are converting and forget to put a content_for block around the code, your view will render empty.

New Layout, Contact Lists, Registration/Forgot Password Added

I just pushed out a large upgrade that I did while on Jury Duty and at Rails Conf. New features include:

  • New design (Much cleaner and easier for me to group elements)
  • Removed extra pages for managing cars, flights, and hotel rooms (I’m trying to keep all of the main work flow on one page.
  • Added the ability to maintain a contact list. Contact lists are a grouping of people who you’ve already been on a trip with. So if you do the same type of trip with the same people all the time, you can just add all from that contact list. Contact lists are managed on the user’s homepage and invitations are sent from the invite page (linked from the trip overview page).
  • Registration: The register link is now visible and now works. Also, if a person wants to change their info from an invitation, it will register them as well.
  • Forgot Password: if you forget your password, you can now click a link and get an email that will let you reset it. This was a big stopping block to going public.