title: Passing parameters to Rails partial
body: <p>In my Rails 4.2.1 app I have <code>Posts</code> and <code>Comments</code> (which are nested within <code>Posts</code>): </p>
  
  <pre class="lang-rb prettyprint-override"><code>   # config/routes.rb
  
     resources :posts do
        resources :comments
     end
  </code></pre>
  
  <p>I have the following Comments partial:</p>
  
  <pre class="lang-rb prettyprint-override"><code>   # app/views/comments/_comment.html.erb
  
     &lt;%= comment.body %&gt;
  </code></pre>
  
  <p>I'm trying to render that partial from within a <code>Posts</code> view:</p>
  
  <pre class="lang-rb prettyprint-override"><code>   # app/views/posts/show.html.erb
  
     &lt;% @comments.each do |comment| %&gt;
       &lt;%= render 'comments/comment', :locals =&gt; { :comment =&gt; comment } %&gt;
     &lt;% end %&gt;
  </code></pre>
  
  <p>The problem is that I'm getting an <em>undefined local variable or method "comment"</em> error when trying to render the partial.</p>
  
  <p>I'm pretty new to Rails but it looks to me like I am passing the <code>comment</code> variable to the partial correctly. Am I missing something obvious?</p>
  
  <p>Thanks</p>
  
  <p><strong>Update</strong></p>
  
  <p>I was looking in the wrong spot in the documentation. See <a href="http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials" rel="nofollow noreferrer">http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials</a></p>
  
  <p><img src="https://i.stack.imgur.com/uCP7V.png" alt="enter image description here"></p>