Closed dzhikvas closed 6 years ago
I'm facing the same issue. In the meantime, including gem "jbuilder"
in the Gemfile makes it work for jb.
Hello there. Any news about this? 😊
As a work around until this gets merged, add what you need to ApplicationController
:
include ActionController::Helpers
include ActionController::ImplicitRender
include ActionView::Rendering
OK, I'm convinced, finally. I mean, no one actually convinced me but I just reconsidered about this issue and changed my mind. I just merged #15 that includes the patch here plus a test.
Basically I really really don't like the approach here. I was aware of this "issue" since I firstly created this gem. But since AC::API is designed as a minimalists' api toolkit, I didn't want to automatically extend it (and make it probably slightly slower) under the hood. Users of this kind of tool have to deeply understand what they are doing, and carefully configure their stack. For those who are not comfortable with that manner should choose the default stack (in this case, AC::Base).
So I intentionally designed this not to touch the renderer by default, but I realized from the users' issue reports that AC::API + jb renders nothing without raising an error (because AC::API doesn't even call default_render
), and so it's very hard to guess how to actually "fix" the problem.
Since now I changed my policy and I chose to follow the "user-friendly" jbuilder way from the next release, the users will never hit this "jb renders nothing!" problem again, in exchange for a little bit thicker API base class.
@amatsuda Thank you for merging this and sharing your vision about it 😊
By default, in Rails API mode, which was introduces since Rails 5,
jb
views don't work.By inspecting
jbuilder
s codebase, I noticed that some additional initialization code is required for templates to work, so here is a fix. Copied from railtie.rb