<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>holybible_2012</title>
    <link>https://ruby-china.org/holybible_2012</link>
    <description/>
    <language>en-us</language>
    <item>
      <title>新手求助 view 问题</title>
      <description>&lt;p&gt;出错信息如下
undefined method `name' for nil:NilClass&lt;/p&gt;

&lt;p&gt;Extracted source (around line #26):&lt;/p&gt;

&lt;h3&gt;评论&lt;/h3&gt;

&lt;p&gt;&amp;lt;% if !@article.comments.nil? %&amp;gt;
&amp;lt;% &lt;a href="/article.comments.eac" class="user-mention" title="@article.comments.eac"&gt;&lt;i&gt;@&lt;/i&gt;article.comments.eac&lt;/a&gt;h do |comment| %&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;%= link_to comment.author.name, user_path(comment.author) %&amp;gt;:&amp;lt;%= comment.content %&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;% end %&amp;gt;
&amp;lt;% end %&amp;gt; &lt;/p&gt;

&lt;p&gt;但是我在 model 中有写
&lt;code&gt;class Comment &amp;lt; ActiveRecord::Base
  belongs_to :article
  belongs_to :author, class_name: "User", foreign_key: "user_id"
end&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;`class Article &amp;lt; ActiveRecord::Base
  belongs_to :owner, class_name: "User", foreign_key: "user_id"
  belongs_to :sub_category
  has_many :comments&lt;/p&gt;

&lt;p&gt;attr_accessor :document
end`&lt;/p&gt;

&lt;p&gt;`class User &amp;lt; ActiveRecord::Base
  has_many :articles
  has_many :comments&lt;/p&gt;

&lt;p&gt;has_secure_password
end`
能指点下可能出错的原因吗&lt;/p&gt;</description>
      <author>holybible_2012</author>
      <pubDate>Wed, 10 Dec 2014 19:45:53 +0800</pubDate>
      <link>https://ruby-china.org/topics/23127</link>
      <guid>https://ruby-china.org/topics/23127</guid>
    </item>
  </channel>
</rss>
