lets say I have a method as follows
def index
applications = Application.all
render json: applications, each_serializer: ApplicationIndexSerializer, status: 200
end
now this works and it returns me my custom serializer, but if I want to add custom keys to the payload like {data: application} it stops working.
however when I change the render method to
render json: {meta: {}, data: applications}, each_serializer: ApplicationIndexSerializer, status: 200
it throughs an error or the serializer does not get hit.
You probably want something like this:
render json: applications, each_serializer: ApplicationIndexSerializer, meta: {}, status: 200
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.