title: Rails + Haml: Returning from a partial will somehow remove the form tag
body: <p>This is lengthy, yes, I apologize. But I want to be clear because this issue is so odd.</p>
  
  <p>I have a terms of service modal that comes up whenever a user has not accepted our terms of service (TOS). For the purposes here, javascript is turned off and what is rendered is strictly html/css. So the page, if thought of in 3 layers, is: bottom layer = page they came to see (i.e. an event page), middle layer: a semi-opaque overlay, top (primary/visible) layer: a modal with the terms of service agreement form in it. This form is simply an accept checkbox and submit button.</p>
  
  <p>I noticed that the TOS was not working properly, but at seemingly random times. Then I noticed that it was broken but only on my event page (/event/foo) even though the same partial is responsible for showing the terms of service agreement no matter where they show up on the site. So for any other page, like /group/bar, the same TOS modal would show up and would work fine.</p>
  
  <p>I then realized that the problem was that the form tag was missing from my HTML! Just gone. </p>
  
  <p>So, taking a step back, the (HAML) code in question is simply:</p>
  
  <pre><code>%div#accept_tosC
    %b Before form_for
    - form_for @current_user do |form|
      %b After form_for
      %div#tosC= render :partial =&gt; 'general/terms'
  
      %div.left
        = render :partial =&gt; 'shared/user/tos_form_element'
      %div.right
        = image_submit_tag "/images/buttons/submit_100x20.png", :id =&gt; 'submit', :name =&gt; 'submit'
  </code></pre>
  
  <p>For our /events/foo page, the generated HTML look like this:</p>
  
  <pre><code>&lt;div id="accept_tosC"&gt;
     &lt;b&gt;before form_for&lt;/b&gt;
    &lt;div style="margin: 0pt; padding: 0pt;"&gt;&lt;input type="hidden" value="put" name="_method"&gt;&lt;input type="hidden" value="44c2bf7a64fc59baa3fc7129167f0e2c3e96abb6" name="authenticity_token"&gt;&lt;/div&gt;
        &lt;b&gt;after form_for&lt;/b&gt;
  </code></pre>
  
  <p>The obvious question here is if 'Before form_for' and 'After form_for' make it into the document, why doens't the form tag form_for creates?</p>
  
  <p>For a different page, say /groups/foo, we get exactly what we would expect:</p>
  
  <pre><code>&lt;div id="accept_tosC"&gt;
    &lt;b&gt;before form_for&lt;/b&gt;
    &lt;form method="post" id="edit_user_595" class="edit_user" action="/users/595"&gt;&lt;div style="margin: 0pt; padding: 0pt;"&gt;&lt;input type="hidden" value="put" name="_method"&gt;&lt;input type="hidden" value="44c2bf7a64fc59baa3fc7129167f0e2c3e96abb6" name="authenticity_token"&gt;&lt;/div&gt;
      &lt;b&gt;after form_for&lt;/b&gt;
  </code></pre>
  
  <p>I tracked it down to a single partial well inside the code for the "bottom" layer (the page they requested, not the TOS overlay). This partial in question may or may not be viewable to any given individual so we have to check if the user can view this page. The result of that is held in the variable can_view:</p>
  
  <pre><code>:ruby
    #some processing to set page info and can_view
    return unless can_view
  
  %div#statsC
    ...and so on...
  </code></pre>
  
  <p>This is what my code looked like and the form tag did <em>not</em> render. By making the following change, the form element tag showed up as expected for all pages:</p>
  
  <pre><code>:ruby
    #some processing to set page info and can_view
  
  - if can_view
    %div#statsC
      ...and so on...
  </code></pre>
  
  <p>So here is the question: Why would returning from a partial prevent a form element tag from becoming part of the document?</p>