Class: Blogit::CommentsController

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

Overview

Handles requests for creating Blogit::Comments

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from ApplicationController

blogit_conf, #blogit_conf

Instance Attribute Details

- (Object) comment (readonly)

Accessor method for the comment being created

Returns:

  • a Blogit::Comment



9
10
11
# File 'app/controllers/blogit/comments_controller.rb', line 9

def comment
  @comment
end

- (Object) post (readonly)

Accessor method for the Post we're adding a Comment to

Returns:

  • Post



14
15
16
# File 'app/controllers/blogit/comments_controller.rb', line 14

def post
  @post
end

Instance Method Details

- (Object) create

Handles POST requests to /blogit/comments.html and /blogit/comments.js



17
18
19
20
21
22
23
24
25
# File 'app/controllers/blogit/comments_controller.rb', line 17

def create
  set_post_from_post_id
  set_comment_as_new
  comment.save
  respond_to do |format|
    format.js   { create_respond_to_js }
    format.html { create_respond_to_html }
  end
end