title: Loopback issues when adding relations
body: <p>I have a Loopback API in which I have a <a href="https://github.com/strongloop/loopback-example-storage" rel="nofollow">container</a> and I'm trying to add some relations to my models (using <a href="https://github.com/strongloop/loopback-example-access-control" rel="nofollow">this</a>) but when it comes to adding relations to container.js, it does not work anymore and I get this error :</p>
  
  <pre><code>/home/mowso/Documents/loopback-examples/test/node_modules/loopback-datasource-juggler/lib/datasource.js:434
            modelClass[relation.type].call(modelClass, name, params);
                                     ^
  
  TypeError: Cannot read property 'call' of undefined
      at EventEmitter.&lt;anonymous&gt; (/home/mowso/Documents/loopback-examples/test/node_modules/loopback-datasource-juggler/lib/datasource.js:434:36)
      at EventEmitter.g (events.js:260:16)
      at emitOne (events.js:77:13)
      at EventEmitter.emit (events.js:169:7)
      at DataSource.setupDataAccess (/home/mowso/Documents/loopback-examples/test/node_modules/loopback-datasource-juggler/lib/datasource.js:540:14)
      at DataSource.attach (/home/mowso/Documents/loopback-examples/test/node_modules/loopback-datasource-juggler/lib/datasource.js:752:8)
      at Function.ModelClass.attachTo (/home/mowso/Documents/loopback-examples/test/node_modules/loopback-datasource-juggler/lib/model-builder.js:336:16)
      at Registry.configureModel (/home/mowso/Documents/loopback-examples/test/node_modules/loopback/lib/registry.js:238:15)
      at configureModel (/home/mowso/Documents/loopback-examples/test/node_modules/loopback/lib/application.js:441:16)
      at EventEmitter.app.model (/home/mowso/Documents/loopback-examples/test/node_modules/loopback/lib/application.js:133:5)
  </code></pre>
  
  <p>I have three models like in the example I link above, they basically just have different names. Here is my container.json :</p>
  
  <pre><code>{
    "name": "Container",
    "base": "PersistedModel",
    "properties": {
      "name": {
        "type": "string"
      }
    },
    "validations": [],
    "relations": {
        "user": {
        "type": "belongsTo",
        "model": "user",
        "foreignKey": "ownerId"
      }
    },
    "acls": [],
    "methods": {}
  }
  </code></pre>
  
  <p>and my user.json :</p>
  
  <pre><code>{
    "name": "user",
    "base": "User",
    "idInjection": true,
    "options": {
      "validateUpsert": true
    },
    "properties": {},
    "validations": [],
    "relations": {
      "containers": {
        "type": "hasOne",
        "model": "Container",
        "foreignKey": "ownerId"
      },
      "companies": {
        "type": "hasOne",
        "model": "company",
        "foreignKey": "ownerId"
      }
    },
    "acls": [],
    "methods": {}
  }
  </code></pre>
  
  <p>Here is the model-config.json :</p>
  
  <pre><code>{
    "_meta": {
      "sources": [
        "loopback/common/models",
        "loopback/server/models",
        "../common/models",
        "./models"
      ],
      "mixins": [
        "loopback/common/mixins",
        "loopback/server/mixins",
        "../common/mixins",
        "./mixins"
      ]
    },
    "User": {
      "dataSource": "db"
    },
    "AccessToken": {
      "dataSource": "db",
      "public": false
    },
    "ACL": {
      "dataSource": "db",
      "public": false
    },
    "RoleMapping": {
      "dataSource": "db",
      "public": false
    },
    "Role": {
      "dataSource": "db",
      "public": false
    },
    "Container": {
      "dataSource": "myfile",
      "public": true
    },
    "user": {
      "dataSource": "db",
      "public": false
    },
    "company": {
      "dataSource": "db",
      "public": false
    }
  }
  </code></pre>
  
  <p>and finally my datasource.json, notice that I have a storage folder at the root of my project :</p>
  
  <pre><code>{
    "db": {
      "name": "db",
      "connector": "mongodb"
    },
    "myfile": {
      "name": "myfile",
      "connector": "loopback-component-storage",
      "provider": "filesystem",
      "root": "storage"
    }
  }
  </code></pre>