Rails Application Templates for Marionette Projects and Generators
After developing conventions for working with Backbone/Marionette, I wrote my own rails generators and application template. These remove a lot of unnecessary files, and sets up sensible defaults for working with Backbone/Marionette projects.
The marionette-template.rb
is an application template used when creating a new rails application. To use this application template, in the terminal type:
rails new APPNAME -m https://raw.github.com/brian-mann/rails-generators/master/marionette-template.rb
app/assets/images/rails.png
imagepublic/index.html
fileREADME.rdoc
to README.md
application#index
app/views/application
directoryapp/views/application/index.html.erb
fileapp/assets/stylesheets/apps
directoryapp/assets/stylesheets/app/_base.css.scss
fileapp/assets/stylesheets/application.css
to application.css.scss
require self
and require tree .
from application.css.scss
filetwitter/bootstrap
and apps/_base
SCSS filesjquery_ujs
and require_tree .
from app/assets/javascripts/application.js
fileTo access these generators, copy the generators
folder into your lib
directory. Now run the install command below:
rails g marionette:install
Installation will do the following:
app.js.coffee
rails g marionette:config
by defaultrails g marionette:config
Configuration will do the follow:
config/initializers/marionette.rb
still store your answers for use when other generators run.
rails g marionette:module MODULENAME [controllers]
This will create a module_app file and initial directory with corresponding AppRoutes for the passed in controller actions. This will also automatically generate the controllers, views, and initial layout template. Use this command to scaffold out your initial app modules.
Example: rails g marionette:module Users list show
would create:
rails g marionette:controller MODULENAME [controllers]
This creates the same controller/view/template combination as above without creating the initial module_app file. Use this to add controllers to an existing app module.
rails g marionette:entity MODELNAME
This will create a model, and ask to also create the corresponding collection along with the App.request handlers for returning the instances.