title: Models Logic in View--Rails
body: <p>My <code>Article</code> model <code>has_many</code> instances of my <code>Comment</code> model, which has a <code>text</code> attribute.</p>
  
  <p>However, in my view, when I call through iteration <code>article.comments.last.text</code> I get <code>undefined method</code> error.</p>
  
  <p>I must say that when I call it through the console, <em>it does return the text attribute</em>.</p>
  
  <p>The log's only relevant response to this error is:</p>
  
  <pre><code>ActionView::Template::Error (undefined method `text' for nil:NilClass):
  </code></pre>
  
  <p>View code:</p>
  
  <pre><code>- @articles.each do |article|
      .article
          %comment= article.comments.last.text 
  </code></pre>