-
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
No rendering in 5.1 #405
Comments
Isn't that normal ? Isn't ActionController::API made so that it's skips a a lot of view rendering inclusion in the controller since it's not supposed to render html ? (which means, no view folder). wouldn't it be better to convert your view with ActiveModel::Serializers ? |
I personally prefer using Jbuilder over ActiveModel::Serializers. It's a little simpler to maintain different serializations for different rails actions. Using rails 5.1.6. |
I am also experiencing this or a related issue (it provoked a stack-overflow question) where I was successfully rendering with 5.1.6, but once I started including AccessGranted gem, Your fix above does work for me, however it also seems to introduce complications for controllers with actions that aren't supposed to render with jbuilder. update I was able to determine that the gem causing me trouble was loading |
Looks like duplicate #346 |
After upgrading my Rails API-only app to 5.1 from ~> 5.0.0 I immediately had issues rendering my Jbuilder templates. The response body would just be blank:
""
I am also using the latest version of Jbuilder
Googling around I found that I was not the only person having this issue. One person suggested an easy fix that worked:
Making sure that one Module was included fixed the problem. Poking around the Jbuilder source code I found some relevant lines in the
jbuilder/railtie.rb
This initializer hook should include the needed module in
ApiRendering
, which is included inActionController::API
. This makes sense from an ancestry POV as opposed to including directly intoActionController::API
, and it probably works most of the time, but for whatever reason it's not working for me and a bunch of other people, maybe because of some other configuration or dependency. It seems that since the same initializer hook is including other modules directly intoActionController::API
, we could do that forActionView::Rendering
, like this:I tried out this change locally in my app's gem source code and it works. I also wrote a simple test that checks if the module is included after calling
Jbuilder::Railtie.run_initializers
, and the tests pass both the old way and the new way. Unfortunately the old way doesn't work for everyone it seems, this seems more surefire.The text was updated successfully, but these errors were encountered: