Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Emil Tin's Profile

GitHub User: emiltin


Comments by Emil Tin


figured it out. it was problems with indentation, which meant that the code which was supposed to be in init() was actually outside the method, and was being called before the router was loaded. small gotcha for someone not used for coffeescript.


nice tutorial!

but i can't initialize the router. i get an error telling me that "Bb.Routers.Entries is not a contructor". (my app is called Bb instead of Raffler.) i suspect this is related to load order, but get find a way to fix it.


window.Bb =
  Models: {}
  Collections: {}
  Views: {}
  Routers: {}
  init: ->
        new Bb.Routers.Entries()     <--- this is the offending line

$(document).ready ->

file entries_router.js.cofee:

class Bb.Routers.Entries extends Backbone.Router
                '': 'index'
        index: ->
                alert 'homepage'

file application.js:

//= require jquery
//= require jquery_ujs
//= require underscore
//= require backbone
//= require bb
//= require_tree ../templates
//= require_tree ./models
//= require_tree ./collections
//= require_tree ./views
//= require_tree ./routers
//= require_tree .

gem versions:
backbone-on-rails (
rails (3.2.1)
coffee-rails (3.2.2)