title: Recursive partial local variables are not working
body: <p>I'm using the <code>ancestry</code> gem to create nested comments.</p>
  
  <p>In the related Railscasts episode, he uses a helper method which uses a lot of <code>content_tag</code>'s... but my partial is quite complex and I don't want to do it that way (I want it in embedded ruby).</p>
  
  <p>The problem is that when a partial is being rendered recursively, the local variables are not being passed.</p>
  
  <p>Initial rendering of comments (where the recursion starts):</p>
  
  <pre><code>def index
    @comments = @commentable.comments.includes(:user).arrange(order: :created_at)
    render partial: 'shared/comments', locals: { comments: @comments }
  end
  </code></pre>
  
  <p>That creates a hash of nested objects. From there, the partial should take over:</p>
  
  <pre><code>&lt;% comments.each do |comment, child_comments| %&gt;
    &lt;div class="comment" data-id="&lt;%= comment.id %&gt;"&gt;
      &lt;%= image_tag comment.user.avatar_url, class: 'avatar', size: '40x40' %&gt;
      &lt;div class="content"&gt;
          &lt;%= simple_format h(comment.body) %&gt;
        &lt;!-- binding.pry --&gt;
        &lt;%= render('shared/comments', locals: { comments: child_comments }) if child_comments %&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>However, when I run this I get <code>undefined local variable or method 'comments'</code> referencing line 1 of the partial above. This only happens on the recursive 2nd loop though (and I assume any beyond that), the initial loop works fine.</p>
  
  <p>I know the variables are correct because immediately before the render call you will see I put <code>&lt;!-- binding.pry --&gt;</code>. If I use pry there I can see that <code>comments</code> do indeed have the proper values.</p>
  
  <p>I'm not sure what to do here... thanks!</p>