paulmillr/brunch-with-chaplin — pull request #31 by akre54 (2012-09-04 06:32:00+00:00)
Title: Fix infinite import loop in generated collection file

This fixes an infinite require loop where the collection would attempt to import itself at the top of its own file. This is because the collection uses `{{name}}` for the model's name as well as in the generator for the collection.

The correct incantation seems to be to use the singular name for both the model and collection generator:
* `brunch g model filter`
* creates **models/filter.coffee** and **test/models/filter_test.coffee**
* `brunch g collection filter`
* creates **models/filters.coffee** and **test/models/filters_test.coffee**

See that the collection filename looks almost identical to the model filename.

Personally I'm a fan of using `models/{{pluralName}}_collection.coffee` rather than just `models/{{pluralName}}.coffee`, since I think it removes some ambiguity.