Created
July 3, 2014 03:54
-
-
Save cthornton/b5fbdafb33c92466f19f to your computer and use it in GitHub Desktop.
Blog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostsController < ApiController | |
def update | |
@post = current_user.posts.find_by(id: params[:id]) | |
# For error message | |
if !@post | |
return render json: { error: 'Unable to find blog post' }, status: :not_found | |
end | |
if [email protected]_attributes(param[:post]) | |
return render json: { | |
error: "Could not update post", | |
validation: @post.errors, | |
}, status: :unprocessable_entity | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment