flatiron/resourceful — Issue #31: Hierarchy relationships misnomer?
Author: coreyjewett
Created: 2011-12-15 08:02:03+00:00
State: open

Was just reading wiki on [Hierarchy relationships](https://github.com/flatiron/resourceful/wiki/Hierarchy-relationships). Cool.

I object to the method name #parent(). It is not accurately descriptive of the relation. In the Shakespeare example given the method should be #belongs_to (keep reading, this isn't right either). As in:

``` js
Book = resourceful.define('book', function () {
this.property('title');
this.belongs_to('Author');
});
```

There is a #has_many implicit in the current implementation that perhaps should be explicit:

``` js
Author = resourceful.define('author', function () {
this.property('name');
this.has_many(Book);
});```

Finally, since I'm picking on this example, I'm not sure #belongs_to is not appropriate because a book can have multiple Authors.

I think this feature should be pulled (or at least renamed from #parent) until some of the magic is stripped out and it follows proper relation modeling and terminology. Ruby on Rails' ActiveRecord might be a good case study for this.