fixes #2822: Post vote API: returns 200 for both success and failure; fixes bug with x-api-limit header

This commit is contained in:
Albert Yi
2017-01-09 17:28:34 -08:00
parent f2a5d45db0
commit 5445b341bc
8 changed files with 31 additions and 17 deletions

View File

@@ -5,8 +5,9 @@ class PostVotesController < ApplicationController
def create
@post = Post.find(params[:post_id])
@post.vote!(params[:score])
rescue PostVote::Error => x
rescue PostVote::Error, ActiveRecord::RecordInvalid => x
@error = x
render status: 500
end
def destroy
@@ -14,5 +15,6 @@ class PostVotesController < ApplicationController
@post.unvote!
rescue PostVote::Error => x
@error = x
render status: 500
end
end