我通过覆盖 JSONAPI::ResourceController 控制器中的创建操作实现了我自己的对象创建逻辑。
创建成功后,我想渲染创建的对象表示。
如何使用 jsonapi-resources gem 呈现这个自动生成的 JSON API 响应?
调用 super 方法也会触发默认的资源创建逻辑,所以这对我来说不起作用。
class Api::V1::TransactionsController < JSONAPI::ResourceController
def create
@transaction = Transaction.create_from_api_request(request.headers, params)
# render automatic generated JSON API response (object representation)
end
end