Folder Structure for Backbone without Requirejs

Asked

Viewed 235 times

5

The goal

Assemble a sufficient and intelligent folder structure for an application Rails 4 + Backbone.

The problem

How am I in the Rails 4 and I yet I can’t handle the Asset Pipeline of him + the RequireJS (and there is a gemstone that does this for the current version), would like to know a good folder structure for my application.

  • 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

  • @Silvio Capitalize models, Collections and etc. in a single file is a good practice?

  • @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

1 answer

3


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/.

  • Sprockets is the Rails requirejs then. That’s it?

  • This, you can manage the dependencies according to your needs, among other things: https://github.com/sstephenson/sprockets#Managing-and-bundling-dependencies

  • Thanks Thiago! Resolvesso!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.