Best practices for loading a template according to object :id?


#1

I have a group model that is pulling in a bunch of groups from an outside api.

My model looks like this:

Mdm.Group = Ember.Object.extend()

Mdm.Group.reopenClass
  all: ->
    Mdm.ajax(
      url: Mdm.apiUrl('/groups')
    ).then (data) ->
      console.log data
      groups = []
      for group in data.response
        groups.addObject(Mdm.Group.create(group))
       console.log(groups)
      groups

  find: (group_id) ->
    Mdm.ajax(
      url: Mdm.apiUrl("/groups/#{group_id}")
    ).then (data) ->
      renderTemplate: (data)

And my routes:

Mdm.GroupsRoute = Ember.Route.extend
  model: ->
    Mdm.Group.all()

Mdm.GroupRoute = Ember.Route.extend
  model: (params) ->
    console.log 'oh hai'
    Mdm.Group.find(params.group_id)

So the group template fails to load when manually entering in a url with a :group_id, ‘/groups/:group_id’.

The group object is being loaded, which is evident by my console output. But I’m curious what the ember way is to load the group template when manually entering an id? I thought this functionality came free with ember but apparently it doesn’t when you’re using an outside api, or leaving ember data out.