Class: CommentsController

Inherits:
BaseController show all
Defined in:
app/controllers/comments_controller.rb

Instance Method Summary collapse

Methods included from BlogHelper

#blog_base_url, #this_blog

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/comments_controller.rb', line 6

def create
  options = new_comment_defaults.merge comment_params.to_h
  @comment = @article.add_comment(options)

  remember_author_info_for @comment

  partial = "/articles/comment_failed"
  partial = "/articles/comment" if recaptcha_ok_for?(@comment) && @comment.save
  respond_to do |format|
    format.js { render partial }
    format.html { redirect_to URI.parse(@article.permalink_url).path }
  end
end

#previewObject



20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/comments_controller.rb', line 20

def preview
  return render plain: "Comments are closed" if @article.comments_closed?

  if comment_params[:body].blank?
    head :ok
    return
  end

  @comment = @article.comments.build(comment_params)
end