Class: Proclaim::CommentsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Proclaim::CommentsController
- Defined in:
- app/controllers/proclaim/comments_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/proclaim/comments_controller.rb', line 9 def create @comment = Comment.new(comment_params) errors = Array.new = Hash.new [:success_json] = lambda {comment_json(@comment)} [:failure_json] = lambda {errors} [:operation] = lambda do if @comment.save return true else errors += @comment.errors. return false end end # Don't leak that the post actually exists. Turn the "unauthorized" # into a "not found" [:unauthorized_status] = :not_found handleJsonRequest(@comment, ) do if antispam_params[:answer] != antispam_params[:solution] respond_to do |format| format.json { render json: ["Antispam question wasn't answered correctly"], status: :unprocessable_entity } end end end end |
#destroy ⇒ Object
44 45 46 47 48 |
# File 'app/controllers/proclaim/comments_controller.rb', line 44 def destroy handleJsonRequest(@comment) do @comment.destroy end end |
#update ⇒ Object
38 39 40 41 42 |
# File 'app/controllers/proclaim/comments_controller.rb', line 38 def update handleJsonRequest(@comment, operation: lambda {@comment.update(comment_params)}, success_json: lambda {comment_json(@comment)}) end |