I have a user model with 2 associated models profile and work capabilities. The user has one profile, but many work capabilities for different types of work. I want to list them as a combined json object like the following using jbuilder:
{profile: { first_name: ...,
last_name: ...,
...
work_capabilities: [ { capability_1: ...,
...
},
...
]
}
}
Currently, I can achieve this by explicitly listing all the profile keys and using json.extract!
json.profile do
json.extract! @profile, :first_name, ...
json.work_capabilities @work_capabilities
end
My question is, can I create the above object without explicitly listing all the profile attributes? I want every attribute in the profile and would prefer not to have to go back and edit the jbuilder file every time I add an attribute.