Class: Commontator::CommentsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Commontator::CommentsController
- Defined in:
- app/controllers/commontator/comments_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /1/comments.
-
#delete ⇒ Object
PUT /comments/1/delete.
-
#downvote ⇒ Object
PUT /comments/1/downvote.
-
#edit ⇒ Object
GET /comments/1/edit.
-
#new ⇒ Object
GET /1/comments/new.
-
#undelete ⇒ Object
PUT /comments/1/undelete.
-
#unvote ⇒ Object
PUT /comments/1/unvote.
-
#update ⇒ Object
PUT /comments/1.
-
#upvote ⇒ Object
PUT /comments/1/upvote.
Instance Method Details
#create ⇒ Object
POST /1/comments
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/commontator/comments_controller.rb', line 22 def create @comment = Comment.new(params[:comment]) @comment.thread = @thread @comment.commontator = @commontator raise SecurityTransgression unless @comment.can_be_created_by?(@commontator) if @comment.save @thread.subscribe(@commontator) if @thread.config.auto_subscribe_on_comment @thread.mark_as_unread_except_for(@commontator) SubscriptionsMailer.comment_created_email(@comment, @commontable_url) @thread.comment_created_callback(@commontator, @comment) else @errors = @comment.errors end respond_to do |format| format.html { redirect_to @commontable_url } format.js end end |
#delete ⇒ Object
PUT /comments/1/delete
68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/controllers/commontator/comments_controller.rb', line 68 def delete raise SecurityTransgression unless @comment.can_be_deleted_by?(@commontator) @comment.delete(@commontator) @thread.comment_deleted_callback(@commontator, @comment) respond_to do |format| format.html { redirect_to @commontable_url } format.js { render :delete } end end |
#downvote ⇒ Object
PUT /comments/1/downvote
105 106 107 108 109 110 111 112 113 114 |
# File 'app/controllers/commontator/comments_controller.rb', line 105 def downvote raise SecurityTransgression unless @comment.can_be_voted_on_by?(@commontator) @comment.downvote_from @commontator respond_to do |format| format.html { redirect_to @commontable_url } format.js { render :vote } end end |
#edit ⇒ Object
GET /comments/1/edit
45 46 47 48 49 50 51 52 |
# File 'app/controllers/commontator/comments_controller.rb', line 45 def edit raise SecurityTransgression unless @comment.can_be_edited_by?(@commontator) respond_to do |format| format.html { redirect_to @commontable_url } format.js end end |
#new ⇒ Object
GET /1/comments/new
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/commontator/comments_controller.rb', line 7 def new @comment = Comment.new @comment.thread = @thread @comment.commontator = @commontator raise SecurityTransgression unless @comment.can_be_created_by?(@commontator) respond_to do |format| format.html { redirect_to @commontable_url } format.js end end |
#undelete ⇒ Object
PUT /comments/1/undelete
81 82 83 84 85 86 87 88 89 90 |
# File 'app/controllers/commontator/comments_controller.rb', line 81 def undelete raise SecurityTransgression unless @comment.can_be_deleted_by?(@commontator) @comment.undelete respond_to do |format| format.html { redirect_to @commontable_url } format.js { render :delete } end end |
#unvote ⇒ Object
PUT /comments/1/unvote
117 118 119 120 121 122 123 124 125 126 |
# File 'app/controllers/commontator/comments_controller.rb', line 117 def unvote raise SecurityTransgression unless @comment.can_be_voted_on_by?(@commontator) @comment.unvote :voter => @commontator respond_to do |format| format.html { redirect_to @commontable_url } format.js { render :vote } end end |
#update ⇒ Object
PUT /comments/1
55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/commontator/comments_controller.rb', line 55 def update raise SecurityTransgression unless @comment.can_be_edited_by?(@commontator) @thread.comment_edited_callback(@commontator, @comment) \ if @comment.update_attributes(params[:comment]) respond_to do |format| format.html { redirect_to @commontable_url } format.js end end |
#upvote ⇒ Object
PUT /comments/1/upvote
93 94 95 96 97 98 99 100 101 102 |
# File 'app/controllers/commontator/comments_controller.rb', line 93 def upvote raise SecurityTransgression unless @comment.can_be_voted_on_by?(@commontator) @comment.upvote_from @commontator respond_to do |format| format.html { redirect_to @commontable_url } format.js { render :vote } end end |