def CommentNotifier
if self = @commentable
else
nil
end
end
def create
@comment = @commentable.comments.new(comment_params)
@comment.user = @current_user
if @comment.save
CommentNotifier.call(comment, current_user)
respond_to do |format|
format.html { redirect_to @commentable }
format.js # create.js.erb
end
else
redirect_to cookies[:original_referrer]
flash[:error] = "Comment could not be created."
end
endNameError (undefined local variable or method `comment' for #<BlogPosts::CommentsController:0x00007fd7bfe4c818>
Did you mean? @comment):
app/controllers/comments_controller.rb:18:in `create'
class BlogPosts::CommentsController < CommentsController
before_action :set_commentable
def new
@comment = Comment.new(commentable: @commentable)
end
private
def set_commentable
@commentable = BlogPost.friendly.find(params[:blog_post_id])
end
endCommentNotifier.call(@comment, @current_user)
ArgumentError (wrong number of arguments (given 1, expected 2)):
app/models/comment_notifier.rb:12:in `initialize'
app/models/comment_notifier.rb:5:in `call'
app/controllers/comments_controller.rb:18:in `create'