I have two models that are associated with each other.
Customer has_one :primary_contact
And I would like to pull this data out in a json object so that the primary_contact model is associated with the Customer object.
Right now my controller does this :
@customers = current_account.customers.all
respond_to do |format|
format.json { render :json => @customers.to_json, :layout => false }
end
But I woud like to also include in these customer objects, their primary contact info as well.
How would I go about pulling this information in a associated context so that I get this data in jQuery as :
value.primary_contact.name
Right now, I can pull the json out for the customer object with this :
value.name
value.address
Per the documentation, use the
:includeoption: