title: Link_to another view ruby on rails
body: <p>I am trying to use the link_to feature to link one view to another.  </p>
  
  <p>The view i am calling link_to is app/views/instructors/show.html.erb and that snippet of code looks like this (namely, the second to last line of it)</p>
  
  <pre><code>&lt;% provide(:title, @instructor.login) %&gt;
  &lt;% courses = Course.where(:instructor_ID =&gt; @instructor.id) %&gt;
      &lt;div class="span2"&gt;
        &lt;h1 align=center &gt;&lt;%= @instructor.login %&gt;&lt;/h1&gt;
        &lt;%= link_to "Add course", new_course_path(:instructor_ID\
                  =&gt; @instructor.id), :class =&gt; "btn" %&gt;
          &lt;br&gt;
          &lt;br&gt;
          &lt;%= link_to "Remove course", delete_course_path(courses), :class =&gt; "btn"%&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>The view I am trying to link to is is app/views/courses/show_all.html.erb and looks like this:</p>
  
  <pre><code>&lt;% @courses.each do |course| %&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;%= course.course_name %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= course.instructor_ID %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= link_to 'Show', course %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= link_to 'Edit', edit_course_path(course) %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= link_to 'Destroy', course, :method =&gt; :delete, :data =&gt; { :confirm =&gt; 'Are you sure?' } %&gt;&lt;/td&gt;
    &lt;/tr&gt;
  </code></pre>
  
  <p>delete_course_path routes to app/views/courses/show_all.html.erb shown above.  When I try the code above, I get the following error:</p>
  
  <blockquote>
    <p>undefined method `each' for nil:NilClass</p>
  </blockquote>
  
  <p>At this line:</p>
  
  <pre><code>&lt;% @courses.each do |course| %&gt;
  </code></pre>
  
  <p>Any ideas what i'm missing in my link_to?</p>