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>
你運行遷移?你有沒有試過'rails console'?什麼是確切的錯誤?你停下來開始你的'rails服務器'了嗎? – nathanvda
@nathanvda謝謝。是的,我確實進行了遷移。我還沒有嘗試導軌控制檯。我重新啓動了我的apache服務器 – MKK
@nathanvda我試圖在rails控制檯上做同樣的事情,但它仍然顯示相同的事情**未定義的方法'評論'** – MKK