-
Notifications
You must be signed in to change notification settings - Fork 440
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
Jbuilder renders blank body with rails 5.0 #346
Comments
I think it might be related to rails/rails#19377 which is the default behavior of Rails 5 to return with |
There is no problem with 204 with missing template (espesially it logs |
same problem in 2.6, log said Completed 204 No Content, any update? |
I seem to be getting the same, or very similar issue. My controller is sending back a response with the expected status code of Only changing the version of jbuilder does not seem to impact anything. This was a rails 4 to rails 5 project non api project. And it worked pre-upgrade to rails5/jbuilder If I force it with |
I got the same problem with: when i include some gem (eg. devise, wechat),the controller will return 200 and no content, it even not hit the jbuilder template. And I checked the gem(wechat) which will cause the problem, if i comment these lines out in the gem https://github.com/Eric-Guo/wechat/blob/master/lib/action_controller/wechat_responder.rb.
jbuilder will work again |
My project currently uses a gem that does the including via RSpec.configure do |config|
config.render_views = true
end |
It can be solved by adding class ApplicationController < ActionController::API
include ActionView::Rendering
end |
Hi, I am new to rails and currently developing my first app, so I am not sure what went wrong. I am using rails 5.0.1 and following steps from https://richonrails.com/articles/getting-started-with-jbuilder. Here`s what I found: if my app is created without --api tag, then jbuilder works fine. However, when I create an api-only app, I get 204 No content response, with or without "freefishz"'s step. Let me know if you need any information. Thanks |
@BOOOMKKK Hi, do you have jbuilder in you gemfile? |
@realwol Thanks, I added in and it works! |
Updated to rails 5.2 and this bug is still reproduced. And @freefishz workaround still works. |
I'm getting this issue in latest 5.1, but @freefishz solution doesn't work for me. I include that rendering, and still get an empty response body. I have to manually render json or use a serializer in place of jbuilder. |
@jeremy with Rails 5.1, try this: class ApplicationController < ActionController::API
include ActionView::Rendering
def render_to_body(options)
_render_to_body_with_renderer(options) || super
end
end referenced from https://github.com/Eric-Guo/wechat/issues/165 |
Had the same issue with Rails 6. @freefishz's solution did not work, I had to add I have no idea if that should've been obvious or anything but why isn't this included in the documentation? Virtually every gem documentation starts with this instruction. Omitting it here makes it seem this is already part of Rails and should work out of the box. I'm not sure if that is the case and this is a bug or that's not the case but either way, it would be great to include it in the readme. |
As note if it's in the .gemspec of your project it will not work (204), but it will work if it's in the Gemfile. |
I have latest jbuilder (2.6.0) and latest rails (5.0.0).
API-controller hello:
routes:
When there is no folder
views/hello
it renders204 No Content
.When I add this folder and
hello.json.jbuilder
inside like this:it renders
200 OK
with empty body.With jbuilder (2.4.1) in same situation it renders as expected:
The text was updated successfully, but these errors were encountered: