title: Rails: call a parent model 's attribute in View?
body: <p>here i have 2 simple model with one-many relation:</p>
  
  <pre><code>class Category &lt; ActiveRecord::Base
    attr_accessible :Name
    has_many :items
  
  class Item &lt; ActiveRecord::Base
    attr_accessible :Category_id, :Name, :Price, :Description
    belongs_to :category
  </code></pre>
  
  <p>and I've a View to show info about Item like:</p>
  
  <pre><code>&lt;table&gt;
    &lt;tr&gt;
      &lt;td class="field" style="width: 175px;"&gt;&lt;b&gt;Name:&lt;/b&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= @item.Name %&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td class="field"&gt;&lt;b&gt;Price:&lt;/b&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= @item.Price%&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td class="field"&gt;&lt;b&gt;Category: &lt;/b&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= Category.find(@item.Category_id).Name %&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td class="field"&gt;&lt;b&gt;Description: &lt;/b&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= @item.Description %&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>It's work right. But here I've a question: Is there's another ways to call class <code>Category</code> 's attribute. Something like <code>@item.category.Name</code> which I try but didn't work ( <code>undefined method "Name" for nil:NilClass</code>)</p>