Skip to content

Instantly share code, notes, and snippets.

@cthornton
Created July 3, 2014 03:54
Show Gist options
  • Save cthornton/b5fbdafb33c92466f19f to your computer and use it in GitHub Desktop.
Save cthornton/b5fbdafb33c92466f19f to your computer and use it in GitHub Desktop.
Blog
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