-1

I have list of appointments in @appointments. I can access corresponding customer of an appointment like this

appointment_object.customer

Now I want to render customer partial file which accepts customer object.

This is jbuilder file which renders partial of customer. Problem here is I have @appointments but I want to send corresponding customer inside this partial.(I dont to change customer partial as I know we can do it inside it also.But this is commong partial and I dont to want to change it)

json.customers do
  json.array! @appointments, partial: 'api/v1/customers/customer', as: :customer
end
Cyzanfar
  • 6,997
  • 9
  • 43
  • 81
krishnar
  • 2,537
  • 9
  • 23

1 Answers1

3

Found solution myself

json.customers do
  json.array! @appointments do | app |
    json.partial! 'api/v1/customers/customer', customer: app.customer
  end
end
krishnar
  • 2,537
  • 9
  • 23