You can use the same structure as a project with requirejs with the Asset Rails pipeline. Using a file only for models, Collections and etc depends a lot on the size of your project. Example structure:
javascripts
├── app
│ ├── collections
│ │ ├── ingredients.js
│ │ ├── recipes.js
│ │ └── users.js
│ ├── mediator.js
│ ├── models
│ │ ├── ingredient.js
│ │ ├── recipe.js
│ │ ├── signup.js
│ │ └── user.js
│ ├── router.js
│ └── views
│ ├── _ingredient.js
│ ├── _recipe.js
│ ├── admin.js
│ ├── base_modal.js
│ ├── signup.js
│ ├── topbar.js
│ ├── user.js
└── vendor
├── backbone-0.9.2.js
├── backbone.localStorage-min.js
├── handlebars.js
├── jquery.js
└── underscore.js
In Rails, the difference is that you will make the require’s of the files in a Sprockets file (the application.js by default). Remembering that in Rails the directory of javascripts
begins after app/assets/
.
Check this project https://github.com/dashcoders/djangodash2013/tree/master/django/app/static/js It was developed in Jango, but the folder structure of Backbone vc can use the same
– silviomoreto
@Silvio Capitalize models, Collections and etc. in a single file is a good practice?
– Guilherme Oderdenge
@Hermeoderdenge This depends on the size of your project and your need. In this case you can see that it is a simple application, so there was no need to separate them. If the files are larger and more complex, I suggest you separate them one by one within a folder. For example, a models folder and within this the files with your models
– silviomoreto