title: Why does this locals variable declaration not work?
body: <p>I have an initial partial call that looks like this:</p>
  
  <pre><code> &lt;% events_array.each_with_index do |event, index| %&gt;
       &lt;%= render partial: "events/activities/#{event.action}", locals: {event: event, index: index} %&gt;
           &lt;section class="card-overlay valign-wrapper"&gt;
                 &lt;div class="valign col s12 m6 l4 card-container"&gt;
                        &lt;%= render partial: 'nodes/node', locals: {node: event.eventable.node, node_counter: index} %&gt;
                  &lt;/div&gt;
            &lt;/section&gt;
   &lt;% end %&gt;
  </code></pre>
  
  <p>That calls this <code>nodes/node</code> partial (truncated for brevity):</p>
  
  <pre><code>&lt;div class="col s12 m6 l4 card-container"&gt;
    &lt;div class="card" id="card-&lt;%= node_counter %&gt;"&gt;
      &lt;!-- Card Content --&gt;
      &lt;div class="card-content" style="background-image: url('&lt;%= node.media.try(:thumbnail_url) %&gt;');"&gt;
  </code></pre>
  
  <p>Where I am now getting this error:</p>
  
  <pre><code>undefined local variable or method `node_counter' for #&lt;#&lt;Class:0x007f9067394f50&gt;:0x007f9063b7d8b0&gt;
  </code></pre>
  
  <p>At this line:</p>
  
  <pre><code>&lt;div class="card" id="card-&lt;%= node_counter %&gt;"&gt;
  </code></pre>
  
  <p>Why does the <code>locals</code> option of my <code>render partial:...</code> not take care of this?</p>
  
  <p>Note that the previous locals declaration of the other partial rendering works fine with no errors, so not sure why this doesn't work.</p>
  
  <p><strong>Edit 1</strong></p>
  
  <p>This is the full partial found at <code>app/views/nodes/_node.html.erb</code></p>
  
  <pre><code>&lt;div class="col s12 m6 l4 card-container"&gt;
    &lt;div class="card" id="card-&lt;%#= node_counter %&gt;"&gt;
      &lt;!-- Card Content --&gt;
      &lt;div class="card-content" style="background-image: url('&lt;%= node.media.try(:thumbnail_url) %&gt;');"&gt;
  
        &lt;video id="video_&lt;%= node_counter %&gt;" class="card-video video-js vjs-default-skin" controls preload="none" data-setup="{}"&gt;
          &lt;source src="&lt;%= node.media.try(:zc_mp4_url) %&gt;" type='video/mp4' /&gt;
          &lt;p class="vjs-no-js"&gt;To view this video please enable JavaScript, and consider upgrading to a web browser that &lt;a href="http://videojs.com/html5-video-support/" target="_blank"&gt;supports HTML5 video&lt;/a&gt;&lt;/p&gt;
        &lt;/video&gt;
        &lt;a class="video-close"&gt;&lt;i class="icon-close"&gt;&lt;/i&gt;&lt;/a&gt;
  
        &lt;div class="card-attr"&gt;
          &lt;!-- Favorites --&gt;
          &lt;%= show_favorites_button(node, node_counter) %&gt;
          &lt;%= favorites_count(node) %&gt;
  
          &lt;!-- Comments --&gt;
          &lt;%= comments_count(node) %&gt;
        &lt;/div&gt;
  
        &lt;!-- Tagged Users --&gt;
        &lt;div class="card-tagged-users"&gt;
          &lt;%= render partial: "nodes/tagged_user", collection: node.tagged_users %&gt;
          &lt;span class="tagged-count"&gt;&lt;%= node.cached_num_user_tags %&gt;&lt;/span&gt;
        &lt;/div&gt;
  
        &lt;h3 class="card-title"&gt;&lt;%= node.name %&gt;&lt;/h3&gt;
      &lt;/div&gt;
      &lt;!-- End Tagged Users --&gt;
  
      &lt;!-- Card Meta --&gt;
      &lt;div class="card-meta"&gt;
        &lt;aside&gt;
          &lt;%= image_tag node.user.avatar.url, class: "card-author-avatar", alt: "" %&gt;
        &lt;/aside&gt;
        &lt;section&gt;
          &lt;h6 class="card-author-name"&gt;&lt;%= node.user.name %&gt;&lt;/h6&gt;
          &lt;time class="card-date"&gt;&lt;%= node.created_at.strftime("%B %d, %Y") %&gt;&lt;/time&gt;
          &lt;p class="card-desc"&gt;&lt;%= node.media.description %&gt;
        &lt;/section&gt;
      &lt;/div&gt;
      &lt;!-- End Card Meta --&gt;
  
      &lt;!-- Card Comments --&gt;
      &lt;div class="card-comments-container"&gt;
        &lt;h4 class="card-comments-title"&gt;&lt;%= pluralize(node.comments_count, "Comment") %&gt;&lt;/h4&gt;
        &lt;a class="card-comments-expand"&gt;&lt;i class="icon-arrow-down"&gt;&lt;/i&gt;&lt;/a&gt;
  
        &lt;div class="card-comments"&gt;
          &lt;%= render partial: "nodes/comment", collection: node.comments.includes(:user).order(created_at: :desc) %&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;!-- End Card Comments --&gt;
  
      &lt;!-- Card Input --&gt;
      &lt;div class="card-input"&gt;
        &lt;%= simple_form_for([node, Comment.new], html: { id: "new_comment_card-#{node_counter}"}, remote: true) do |f| %&gt;
         &lt;%= f.error_notification %&gt;
            &lt;%= f.input_field :message, as: :text, id: "card-input-field-card-#{node_counter}", class: "input-field", placeholder: "Share your thoughts", cols: "30", rows: "10", "data-behavior" =&gt; "submit_on_enter" %&gt;
            &lt;%= f.button :submit, "Submit", name: "card_id", value: "card-#{node_counter}", id: "submit-card-#{node_counter}", class: "comment-submit", data: { disable_with: "Submitting Comment..." } %&gt;
        &lt;% end %&gt;
      &lt;/div&gt;
      &lt;!-- End Card Input  --&gt;
    &lt;!-- End Card Content  --&gt;
  
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Edit 2</strong></p>
  
  <p>So, inside Better Errors, at the REPL within the scope of the view that I call the partial on, i.e. the first code snippet in this question, I played around with the console and see that the local variables within the second partial are not being assigned at all, despite their values returning legitimate values:</p>
  
  <pre><code>&gt;&gt; node
  !! #&lt;NameError: undefined local variable or method `node' for #&lt;#&lt;Class:0x007fbf389e01c0&gt;:0x007fbf30cd3358&gt;&gt;
  &gt;&gt; event.eventable.node
  =&gt; #&lt;Node id: 3, name: "Outro", family_tree_id: 1, user_id: 1, media_id: 3, media_type: "Video", created_at: "2015-07-25 04:28:39", updated_at: "2015-08-01 23:11:26", circa: nil, is_comment: nil, cached_votes_total: 0, cached_votes_score: 0, cached_votes_up: 0&gt;
  &gt;&gt; node_counter
  !! #&lt;NameError: undefined local variable or method `node_counter' for #&lt;#&lt;Class:0x007fbf389e01c0&gt;:0x007fbf30cd3358&gt;&gt;
  &gt;&gt; index
  =&gt; 0
  &gt;&gt;
  </code></pre>
  
  <p>Why would the assignment not be happening?</p>