Post#show 要能見到單筆文章

 module ApiV0
   class Posts < Grape::API
    # ...

    desc "Get your post"
    params do
      requires :id, type: String, desc: 'Post ID.'
    end
    get "/posts/:id" do
      post = current_user.posts.find_by(id: params[:id])

      present post, with: ApiV0::Entities::Post
    end

    # ...
   end
 end
Copyright © NicLin 2019 all right reserved,powered by Gitbook該頁面生成時間: 2019-04-09 10:00:37

results matching ""

    No results matching ""