title: rails render collection and locals
body: <p>I am trying to render a partial from within a js.erb file which has both a collection AND a local variable passed to it. Everything works fine except I cannot access the local variable in the view. I have tried the following:</p>
  
  <pre><code>&lt;%= escape_javascript(render(partial: 'tasks/task', collection: @task_group.tasks_belonging_to, as: :task, locals: {testvble: "bob"})) %&gt;
  &lt;%= escape_javascript(render(partial: 'tasks/task', collection: @task_group.tasks_belonging_to, locals: {testvble: "bob"})) %&gt;
  &lt;%= escape_javascript(render(partial: @task_group.tasks_belonging_to, locals: {testvble: "bob"})) %&gt;
  &lt;%= escape_javascript(render(@task_group.tasks_belonging_to, testvble: "bob")) %&gt;
  </code></pre>
  
  <p>Each of the above works until I try to access the local variable in the view. I get the error:</p>
  
  <pre><code>undefined local variable or method `testvble'
  </code></pre>
  
  <p>Just for completeness, each of the above is inside the following statement in the js.erb file (at the xxxx position):</p>
  
  <pre><code>$("#task-group-&lt;%=@task_group.id%&gt;").append("xxxx").hide().show('slow')
  </code></pre>
  
  <p>This is the code in the partial causing the issue:</p>
  
  <pre><code>&lt;p&gt;should be bob:&lt;%= testvble %&gt;&lt;/p&gt;
  </code></pre>