Post#destroy 要能刪除單筆文章
module ApiV0
class Posts < Grape::API
# ...
desc "Delete a post."
params do
requires :id, type: String, desc: 'Post ID.'
end
delete "/posts/:id" do
post = current_user.posts.find_by(id: params[:id])
if post.destroy
present post, with: ApiV0::Entities::Post
else
raise StandardError, $!
end
end
# ...
end
end