I'm using json to store document versions of my data in postgresql. I would like to output an entire tree of objects with children, children of children etc and all attributes. If any attributes are added to any of the objects at a later date, I would like them to be include in subsequent json.
Is there any way to output the entire contents without having to least each and every attribute? ie not like this:
json.(object_name, :id, :attr1, :attr2.... etc)
I know this is an old thread, but I was wondering the same thing, and ended up here. Then I found a great answer here => How to extract all attributes with Rails Jbuilder?
@uiureo suggests to use json.merge!
, and that worked perfactly for me :)
json.merge! object_name.attributes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With