rails / jbuilder

Jbuilder: generate JSON objects with a Builder-style DSL
MIT License
4.34k stars 440 forks source link

jBuilder 2.11.3, Rails 6.1.4.1 fail to render objects that are child of Simpledelegator #523

Open net1957 opened 3 years ago

net1957 commented 3 years ago

In my case, the objects rendered are child of Simpledelegator Class

I get this error as soon I add cached: true to my json.jbuilder view: ActionView::Template::Error (undefined methodnhut' for [#<Cmdmary::Etudprix`

The Cmdmary::Etudprix is the AR object and not the Decorated object (that define nhut) passed to the json.

Jbuilder use also Delegator if cached is true. Perhaps this colide with mine?

Without cached: true, all is working without problem. Any advice how to make this work?

net1957 commented 3 years ago

I have to correct. It fail always wit or without cache;

in fact the error seem's to be a bit bad! image

the partial is: json.CdpHut do json.Hut cdplist.nhut json.Dmaj cdplist.dmaj json.Dtransfer cdplist.dexport end

if I pass directly a AR record it's working as expected with or without cache: true

So I think that the object (that have SimpleDelegatot in parents class) I'm passing is not supported.

but it work if I don't use partials: image

rafaelfranca commented 2 years ago

Can you provide an example application that reproduce the issue?