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

        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

        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)
          else
            values_new.push(value)
        obj[fieldName] = values_new
