how can i to combine acts_as_commentable_with_threading and notification system ?
i got undefined method `users' for #Comment:0x007fb91b018818 Did you mean? user user=
comments_controller
def create
commentable = commentable_type.constantize.find(params["comment"]["commentable_id"])
@comment = Comment.build_from(commentable, current_user.id, body)
respond_to do |format|
if @comment.save
(@comment.users.uniq - [current_user]).each do |user|
Notification.create(repient: user, actor: current_user, action: "posted", notifiable: @comment)
end
@comment.create_activity :create, owner: current_user
make_child_comment
format.html { redirect_to(:back, :notice => 'Comment was successfully added.') }
else
format.html { render :action => "new" }
end
end
end
routes.rb
resources :forums, only: [:index, :show] do
resources :posts, only: [:new, :create]
end
resources :comments, only: [:create, :destroy, :update] do
resources :likes, only: [:create, :destroy]
end
post.rb
class Post < ApplicationRecord
belongs_to :user
belongs_to :forum
has_many :clips, dependent: :destroy
has_many :users, through: :clip
has_many :comments
has_many :users, through: :comments
acts_as_commentable