title: Rails: allowing a partial to only be rendered once
body: <p>Is there a way to code a rails partial such that it can only be rendered once, no matter how many times the containing view attempts to render it?</p>
  
  <p><strong>Why:</strong> A page consists of a series of smaller widget partials.  Each widget has a few small links in the upper right to display "popover" forms, which collect data from the user.  These popovers are partials included by the widget partials.  Clicking these links finds the popover partial in the DOM (by id), displays it, and positions it below the clicked link.  The widget partials have no way of knowing which other widgets are included in this page, but I want to include each required popover once and only once in the DOM.</p>
  
  <p>If this is still confusing, the setup is something like</p>
  
  <ul>
  <li>Page view
  <ul>
  <li>Widget partial 1
  <ul>
  <li>Popover partial A</li>
  </ul></li>
  <li>Widget partial 2
  <ul>
  <li>Popover partial B</li>
  <li>Popover partial C</li>
  </ul></li>
  <li>Widget partial 3
  <ul>
  <li>Popover partial B</li>
  <li>Popover partial D</li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>Here A, B, C, and D should each appear only once in the DOM, despite B being explicitly included twice.</p>
  
  <p>I'm thinking something like <code>#ifndef</code> in C, where we ensure headers are included only once.</p>
  
  <p><strong>Note:</strong> I'm using Rails 2.3</p>