Working on an app that has events
and each event
has many images
Here is the association:
images: DS.hasMany("event-image", { async: true })
The EventImage
Model:
`import DS from 'ember-data'`
EventImage = DS.Model.extend
event: DS.belongsTo("event")
### NATURAL ATTRIBUTES ###
imageUrl: DS.attr("string", { defaultValue: "" })
fileName: DS.attr("string")
fileSize: DS.attr("string")
primary: DS.attr("boolean", { defaultValue: false })
featured: DS.attr("boolean", { defaultValue: false })
`export default EventImage`
When visiting /events/1722/edit
, I am [trying to] display the images like so:
<div class="field">
<label class="label label__text">More images</label>
{{#core-image-multiple-uploader model=model processedFiles=model.images}}
Select additional event photos (10 max).
{{/core-image-multiple-uploader}}
</div>
The JSON API response, returns an attribute that looks like:
"image_ids": [
2474,
2469,
2468
]
When the page loads, I can see the three images on the page, but when attempting to fetch data to load each image, the API route that is called is /api/event_images/2469
. I need to add on the event_id
query param (or even better, have event_images
nested underneath events so that the API call is /events/:event_id/event_images
).
I am on EmberJS v1.10
and am using ActiveModelAdapter
. That looks like this:
`import Ember from 'ember'`
`import DS from 'ember-data'`
ApplicationAdapter = DS.ActiveModelAdapter.extend
host: window.EmberENV.apiURL
headers:
"Accept" : "application/json, text/javascript; q=0.01"
`export default ApplicationAdapter`
I'm an EmberJS newb, dropped into this project, so my apologies here, trying to play catch up.