2013-04-12 23 views
1

我試圖讓這個插件工作。我讀過其他線程,但我似乎沒有得到它。使用acts_as_commentable_with_threading

我想讓我的文章模型評論。這如果我迄今爲止所做的:

正確完成所有安裝。

class CommentsController < ApplicationController 


def create 
    @article = Article.find(params[:id]) 
    @user_who_commented = @current_user 
    @comment = Comment.build_from(@article, @user_who_commented.id, "Hey guys this is my comment!") 
    end 
end 

在文章#顯示:

<%= form_for @comment do |f| %> 
<%= f.text_area :text %> 
    <%= f.submit "Post Comment" %> 
<% end %> 

路線:

devise_for :users 
    resources :dashboard 
    resources :users, :only => [:index,:show,:edit,:update] 
    resources :events 
    resources :januscript do 
    resources :quotes 
    end 
    resources :jmail, :only => [:index, :show] 
    resources :album 
    resources :video, :only => [:index, :show] 
    resources :photos 
    scope '/archive' do 
    resources :quotes, :only => [:index] 
    resources :articles, :only => [:index,:show] 
    end 
    resources :comments 

我收到此錯誤信息:

undefined method `model_name' for NilClass:Class 

回答

1

確保添加acts_as_commentable到您的模型你想要評論。在這裏沒有看到任何模型代碼。

編輯: 您是否在文章的路線中添加了嵌套資源?

resources :articles do 
    resources :comments 
end 
+0

我在文章 – masb

+0

中添加了acts_as_commentable編輯我原來的答案。 – Brett