Folder structure for Backbone without RequireJS

5

The goal

Mount a sufficient and smart folder structure for an application Rails 4 + Backbone .

The problem

As I am in Rails 4 and I still do not know how to deal with Asset Pipeline it + RequireJS (and there is no gem that does this for the current version) know a good folder structure for my application.

    
asked by anonymous 29.01.2014 / 13:07

1 answer

3

You can use the same structure as a project with requirejs with the rails asset pipeline. Using a file just 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). Remember that in Rails the javascripts directory starts after app/assets/ .

    
29.01.2014 / 15:02