Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use to_json when rendering json response
I was trying to debug why an inertia response was 5x slower than the initial page response. After some investigation, it turns out that render json: foo does not actually do the same thing as foo.to_json does. It does a whole lot of rails magic instead, which is both a lot slower and inconsistent. Changing this to use page.to_json ensures consistency with the props output in inertia.html.erb, avoiding weird inconsistencies between props renders and full page renders, and is also a lot faster (especially if you are using a library like Oj to optimise json generation in the first place).
- Loading branch information