Hi,
I’m trying to use JBuilder to generate a JSON to a specific class.
I wan’t to include all attributes, except one or two.
To do that I’m doing:
json.extract! object, :attr1, :attr2, :attr3, :attr4, :attr5, …
There’s an alternative?
Att.
Hi,
I’m trying to use JBuilder to generate a JSON to a specific class.
I wan’t to include all attributes, except one or two.
To do that I’m doing:
json.extract! object, :attr1, :attr2, :attr3, :attr4, :attr5, …
There’s an alternative?
Att.
How about creating an array of what you do want e.g.
wanted = object.attributes.keys.map(&:to_sym) - [:attrX, :attrY]
json.extract! object, *wanted
HTH,