2012-12-28 54 views
1

在社會各界的#show頁面,我得到:爲什麼在使用acts_as_commentable_with_threading時會得到未定義的方法`comments'?

未定義的方法`評論

我想知道爲什麼我得到這個錯誤?

community_topics_controller.rb

def show 
    @community_topic = CommunityTopic.find params[:id] 

    @comment = @community_topic.comments.build 
    @community_topic.comments.pop 

    respond_to do |format| 
    format.html # show.html.erb 
    format.json { render json: @community_topic } 
    end 
end 

型號/ community_topic.rb

acts_as_commentable 

的意見/ community_topics/show.html.erb

<%= render 'comments/form' %> 

的意見/評論/ _form.html.erb

<div class="field"> 
    <%= f.label :comment %><br /> 
    <%= f.text_area :comment %> 
    <%= f.hidden_field :commentable_id %> 
    <%= f.hidden_field :commentable_type %> 
    </div> 
+0

你運行遷移?你有沒有試過'rails console'?什麼是確切的錯誤?你停下來開始你的'rails服務器'了嗎? – nathanvda

+0

@nathanvda謝謝。是的,我確實進行了遷移。我還沒有嘗試導軌控制檯。我重新啓動了我的apache服務器 – MKK

+0

@nathanvda我試圖在rails控制檯上做同樣的事情,但它仍然顯示相同的事情**未定義的方法'評論'** – MKK

回答

4

我找到了答案。
我只要用comment_threads,而不是意見爲我所用「acts_as_commentable_with_threading」

相關問題