title: Access Sinatra variable in partial
body: <p>I'm fairly new to Sinatra, and I'm trying to access data from a database from within a partial.</p>
  
  <p>Here's an example of a partial that I want on a page:</p>
  
  <pre><code>&lt;% @articles.each do |article| %&gt;
      &lt;ul&gt;
          &lt;li&gt; &lt;%= article.articleName %&gt; &lt;/li&gt;
      &lt;/ul&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>It works fine if I just set up a route like</p>
  
  <pre><code>get '/articles' do
       @article = Articles.all
       erb :articles
  end
  </code></pre>
  
  <p>and the /articles page with something like</p>
  
  <pre><code>&lt;% @articles.each do |article| %&gt;
      &lt;article&gt;
          &lt;p&gt; &lt;%= article.articleName %&gt; &lt;/p&gt;
          &lt;p&gt; &lt;%= article.articleBody %&gt; &lt;/p&gt;
      &lt;/article&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>However, it doesn't seem like the above code works if I put it into a partial. </p>
  
  <p>Any help would be appreciated. I'm sure I'm missing something simple.</p>