Smam Smam - 7 months ago 31
Ruby Question

Is there any way to hide attributes in a Rails Jbuilder template?

I know you can explicitly list fields like so,

json.(model, :field_one, :field_two, :field_three)

But is there anything similar to the following,

json.(model, except: :field_two)

which would output all of the model fields except the one called out?


Try json.merge! model.attributes.except("field_one", "field_two")