Class: Blogit::CommentsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Blogit::CommentsController
- Defined in:
- app/controllers/blogit/comments_controller.rb
Overview
Handles requests for creating Blogit::Comments
Instance Attribute Summary collapse
-
#comment ⇒ Object
readonly
Accessor method for the comment being created.
-
#post ⇒ Object
readonly
Accessor method for the Post we’re adding a Comment to.
Instance Method Summary collapse
-
#create {|comment| ... } ⇒ Object
Handles POST requests to /blogit/comments.html and /blogit/comments.js.
Methods inherited from ApplicationController
Instance Attribute Details
#comment ⇒ Object (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 |
#post ⇒ Object (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
#create {|comment| ... } ⇒ Object
Handles POST requests to /blogit/comments.html and /blogit/comments.js
Yields #comment if called with a block (useful for calling super from subclasses)
19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/blogit/comments_controller.rb', line 19 def create set_post_from_post_id set_comment_as_new comment.save yield comment if block_given? respond_to do |format| format.js { create_respond_to_js } format.html { create_respond_to_html } end end |