     set: (model, data) ->
         this._set(model, data, 'set')
         for name, value of data
-            if @definitions[name] && value?.isModel && !value.isNew()
+            if @definitions[name] && Lanes.u.isModel(value) && !value.isNew()
                 model[@pk(name)] = if value then value.getId() else null
 
     setFromServer: (model, data) ->

# ------------------------------------------------------------------ #
# Handles Association definitions.                                   #
# It creates a derived definition for each one                       #
# and contains utility functions to operate on them                  #
# ------------------------------------------------------------------ #
class Lanes.Models.AssocationMap
    constructor: (@klass) ->

        @definitions = @klass::associations
        @definitions['created_by'] ||= { model: 'Lanes.Models.User', readOnly: true }
        @definitions['updated_by'] ||= { model: 'Lanes.Models.User', readOnly: true }
        @collections = {}
        for name, options of @definitions
            @klass::derived[name] = this.derivedDefinition(name, options)

