title: How to define an instance variable from a model used in Rails partial _header
body: <pre><code>application.html.erb
  &lt;html&gt;
  .
  .
  .
  &lt;body&gt;
    &lt;%= render 'layouts/header' %&gt;
      &lt;div class="container"&gt;
        &lt;%= yield %&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  .
  .
  .
  &lt;/html&gt;
  </code></pre>
  
  <p>An instance variable from my Article model is used in a dropdown of the header.</p>
  
  <pre><code>_header.html.erb 
  .
  .
  &lt;li class="dropdown"&gt;
  .
  .
  &lt;%= link_to(@articles.first.source, target: "_blank") do %&gt;
  .
  .
  &lt;/li&gt;
  .
  .
  </code></pre>
  
  <p>Do I have to include @articles = Articles.all in every view, such as: </p>
  
  <pre><code>class PhotosController &lt; ApplicationController
  
  def index 
    @articles = Article.approved.all
  end
  
  def new
    @articles = Article.approved.all
  end
  
  def show 
    @articles = Article.approved.all
  end 
  
  etc 
  </code></pre>
  
  <p>or is there a better way? </p>