Skip to content

Latest commit

 

History

History
43 lines (30 loc) · 1.22 KB

README.rdoc

File metadata and controls

43 lines (30 loc) · 1.22 KB

Rails + Backbone + Marionette + Coffeescript Boilerplate Example

Used gems

  • marionette-rails

  • haml_coffee_assets, execjs

Used libs

  • Backbone.js, Underscore.js, json2

  • Backbone.Marionette

  • Backbone.StickIt (two-way binding)

  • Backbone.Validation

  • backbone_rails_sync (from rails-backbone gem, patches Backbone.sync method for better integration with Rails)

  • Sugar.js (Ruby-like JS core extension)

Advice

  • move javascript_include_tag to be just before </body>

  • to pre-load data, put a script tag at end of body. Example to pre-load current_user:

    <% if current_user.present? %>
      <script type="text/javascript">
        App.current_user = new App.Models.User(<%= current_user.to_json.html_safe %>);
      </script>
    <% end %>
  • or if you use Rabl:

    <% if current_user.present? %>
      <script type="text/javascript">
        App.current_user = new App.Models.User(<%= render('api/v1/users/user.json.rabl', object: current_user).html_safe %>);
      </script>
    <% end %>

Credit

Thanks to github.com/elentok/backbone-marionette-example and rails-backbone gem for a starting point.

Todo

  • make generator

  • on backbone:install, fetch js libs from github master branches and copy them over