PaulUithol/Backbone-relational — Issue #46: HasOne relationship from string
Author: pgherveou
Created: 2011-11-03 16:56:59+00:00
State: open

Hello Paul

when a hasMany relationship is initialized from an array of id it is turned into a collection of model. Wouldn't be useful to have the same behavior for hasOne relationship ?

```javascript
ourHouse = new House({
id: 'house-1',
location: 'in the middle of the street',
occupants: ['person-1', 'person-2', 'person-5']
owner: 'person-1'
});

// 'ourHouse.occupants' is turned into a Backbone.Collection of Persons.
ourHouse.get('occupants').at(0); // === paul
// 'ourHouse.owner' is turned into a Person.
ourHouse.get('owner'); // === paul
```

in the current version setting a string on a hasone relationship set the value to undefined, I guess, this could be updated in the createModel method what do u think ?

```javascript
createModel: function( item ) {
if ( this.options.createModels && typeof( item ) === 'object' ) {
return new this.relatedModel( item );
}
},
```