Accessing polymorphic relations in rails through javascript -
i have model data collected via ajax. model data has polymorphic relation attached it.
some_id: 1, some_type: "foo"
so in controller can do
model.some.name
the problem comes when trying access these attributes javascript. model data rendered json json doesn't contain relationship data.
is there way can this?
you'll need load related data want, either translating returned record(s) explicitly (as in data transfer object) before serializing js, or else using eager loading.
Comments
Post a Comment