jb icon indicating copy to clipboard operation
jb copied to clipboard

Rendering partials inline requires #to_json

Open pyrareae opened this issue 5 years ago • 3 comments
trafficstars

When calling rendering a partial a different template format, such as slim in my case, the render call needs to have #to_json called on it otherwise it returns a ruby hash instead of valid json. I didn't see any heads ups on this in the documentation so I'm not sure if this is intentional behavior or not.

For example, using jbuilder you can use something like this:

render partial: 'entry', object: @entry, formats: :json

whereas with jb you need this:

render(partial: 'entry', object: @entry, formats: :json).to_json

pyrareae avatar Feb 04 '20 02:02 pyrareae

It is correct, because a .jb file returns a hash

sebyx07 avatar Apr 14 '21 12:04 sebyx07