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.

http://blog.arkency.com/2013/12/rails4-preloading/


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -