-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rendering nested JBuilder partials requires formats: [:json] to be passed #134
Comments
Can you make an example app showing how partial lookup fails? That should not happen and must be a bug, but I can't recreate it |
I'm also struggling to re-create this outside of my project. That does suggest it is something peculiar to my setup. I'll close this issue and re-open if I can reproduce it. |
I'm able to recreate this issue any time I'm rendering a jbuilder partial from inside of an html template. |
@sgrif can you isolate this behaviour into a test case or simple rails app? I couldn't manage to recreate it outside of my entire project. |
Yeah, isolated showcase would be very helpful |
Here is simplest rails app to reproduce this issue: https://github.com/ineu/jbuilder-format-example In rails 3.2.13 there's error:
In rails 3.2.14rc warning:
but it passes correct formats: This way it is possible to use jbuilder this way in rails 3.2.14rc2 with no errors or warnings if you change
|
@ineu that is due to a bug in rails that was fixed in 3.2.14: rails/rails#8406 |
@petedmarsh does upgrading to 3.2.14 solve your problem? |
@rwz, with 3.2.14 my example works great, thanks! |
I'm running into this in Rails 6. Perhaps it has regressed? I find |
I'm running in Rails 7. It's solved just set like this. - render 'index', formats: :json, handlers: 'jbuilder'
+ render 'index' I don't understand why I occurred this error. |
I render JSON using inside some HAML views in order to ship along an initial blob of JSON to the client. Since the change in #120 I have found that rendering JSON/JBuilder partials is a little bit more cumbersome as
formats: [:json]
is no longer passed by default.Where previously I had written:
json.partial! 'xs/x', my_local: @some_value
I now have had to change this to:
json.partial! partial: 'xs/x', formats: [:json], locals: { my_local: @some_value }
If I do not pass
formats: [:json]
I get a "Template not found" error. Ideally I'd like to go back to something like the original. Admittedly this only happens as I am rending a JBuilder template with nested partials into a HAML view, so perhaps it is too rare a use case to support directly.My initial thought was a new method which is like
partial!
but can only render other JBuilder templates. After thinking about it for a little while, it's probably not a good solution.The text was updated successfully, but these errors were encountered: