Ok, I'm working on a simple Ember / Rails app, and I'm trying to post a hasMany association in a single HTTP request. For what it's worth, I'm using Rails for the API.
Ember: 1.4.0-beta.1+canary.011b67b8
Ember Data: 1.0.0-beta.5+canary.d9ce2a53
Handlebars: 1.1.1
jQuery: 1.10.2
Release Model
App.Release = DS.Model.extend
name: DS.attr 'string'
tracks: DS.hasMany 'track', {embedded: 'true'}
A "Release" has many "Tracks"
App.ReleasesNewRoute = Ember.Route.extend
model: -> @store.createRecord 'release'
afterModel: (release, transition)->
release.get('tracks').addObject(@store.createRecord 'track',{
name: 'Track 1'
}).pushObject(@store.createRecord 'track',{
name: 'Track 2'
})
setupController: (controller, model)->
controller.set('content', model)
Releases Controller
App.ReleasesNewController = Ember.ObjectController.extend
actions:{
save: ->
@content.save()
}
How can I post the two tracks and one release at once? I'm planning to use accepts_nested_attributes_for :tracks in my Rails API... but I'll be happy if I can see the Tracks in my development console for a start.