Reputation: 95
I want to be able to make an ActiveRecord call (or anything else that might get me the right results) that will pass me all object attributes. For example:
I have a contact model, which can have many "CustomField"'s and many "ServiceAddress"'s
contact =
id:"5"
custom_fields:[{
id:"5"
name:"birthday"
label:"birthday"
}]
service_addresses: [{
id: 'test1'
type: 'email'
address: '[email protected]'
kind: 'home'
},{
id: 'test2'
type: 'email'
address: '[email protected]'
kind: 'other'
},{
id: 'test3'
type: 'email'
address: '[email protected]'
kind: 'other'
}]
first_name:"emily"
kind:”person"
Is there some kind of query I can make to receive something similar?
Thanks!
Upvotes: 0
Views: 76
Reputation: 24337
You can use includes
to specify the associations to load:
Contact.includes(:custom_fields, :addresses).find(5)
Upvotes: 1