         values_new = []
         for value in values
           if angular.isObject(value) or (value instanceof Resource)
-            values_new.push(if value.id? then value.id else null)
+            values_new.push(if value.$id? then value.$id else null)
           else
             values_new.push(value)
         obj[fieldName] = values_new

        value = obj[fieldName]
        continue if not value
        if angular.isObject(value) or (value instanceof Resource)
          obj[fieldName] = if value.id? then value.id else null

      for reference in @constructor.m2m
        fieldName = reference.name


    $save: ->
      data = @_toObject()
      if @$meta.persisted and @$id?
        method = 'PUT'
        url = @_getURLBase() + "#{@$id}"
      else
        method = 'POST'
        if @constructor.idField of data
          delete data[@constructor.idField]
        url = @_getURLBase()

      # TODO: check deferred/promise re-setup
