Skip to content

Instantly share code, notes, and snippets.

@andrewpthorp
Created January 31, 2014 22:24
Show Gist options
  • Save andrewpthorp/8744501 to your computer and use it in GitHub Desktop.
Save andrewpthorp/8744501 to your computer and use it in GitHub Desktop.
Captain.TicketsShowRoute = Ember.Route.extend
model: (params) ->
@store.find('ticket', params['ticket_id'])
setupController: (controller, model) ->
controller.set('model', model)
controller.set('queues', @store.all('queue'))
renderTemplate: ->
@render 'tickets/show'
Captain.Ticket = DS.Model.extend
ticket_number: DS.attr('string')
subject: DS.attr('string')
state: DS.attr('string')
merchant: DS.attr('string')
email: DS.attr('string')
messages: DS.hasMany('message')
queue: DS.attr('string')
Captain.TicketSerializer = DS.ActiveModelSerializer.extend DS.EmbeddedRecordsMixin,
attrs: {
messages: { embedded: 'always' }
}
Captain.Queue = DS.Model.extend
name: DS.attr('string')
unassigned: DS.attr('boolean')
@andrewpthorp
Copy link
Author

What I know is the following:

@store.getById('queue', '12345') returns a Captain.Queue

console.log model.get('queue') on line 6, prints '12345'

However, if I change line 17 to the following:

queue: DS.belongsTo('queue')

console.log model.get('queue') on line 6, prints null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment