On the community’s #show page, I get:
undefined method `comments’
I was wondering why was I get this error?
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
models/community_topic.rb
acts_as_commentable
views/community_topics/show.html.erb
<%= render 'comments/form' %>
views/comments/_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>
I found the answer.
I had to use comment_threads instead of comments as long as I was using ‘acts_as_commentable_with_threading’