title: How do I access an instance variable from another controller?
body: <p>So I have two models &amp; controllers. Projects and Designers.</p>
  
  <p>In my designers index view, I want it to show a list of all the projects that the designer has.</p>
  
  <p>However, when I do a simple query like this:</p>
  
  <pre><code>&lt;% @projects.each do |project| %&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;%= link_to 'Show', project %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= link_to 'Edit', edit_project_path(project) %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= link_to 'Destroy', project, :confirm =&gt; 'Are you sure?', :method =&gt; :delete %&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>From the index.html.erb in the Designers view, it gives me the following error:</p>
  
  <pre><code>NoMethodError in Designers#index
  You have a nil object when you didn't expect it!
  You might have expected an instance of Array.
  The error occurred while evaluating nil.each
  </code></pre>
  
  <p>However, when I run that EXACT code from the index.html.erb file in the projects view, it works perfectly.</p>
  
  <p>So how am I able to access that controller or at least data from the view of another controller? Do I have to add a projects variable (where it queries the db) to my index object in my designers controller?</p>
  
  <p>Thanks.</p>