elabs/serenade.js — Issue #3: Associations Syntax
Author: ktusznio
Created: 2012-01-31 16:45:09+00:00
State: open

When specifying associations in Batman, we found it fairly clean to look for a model based on the name of the association. For example, `Comment.belongsTo 'post'` would look for a `Post` model when an associated record needs to be initialized.

We also provided `name` and `namespace` options.

The `name` option is for associated models which have entirely different names. (ie. `Comment.belongsTo 'post', name: 'article'` would look for the `Article` model.)

The `namespace` option defaults to `Batman.currentApp`, but when it's specified, the model gets looked up under the provided namespace. (ie. `Comment.belongsTo 'post', namespace: 'Wordpress'` would look for a `Wordpress.Post` article.)

Whether you find this cleaner than having the user provide a function is a different question entirely. :)