RailsCasts Pro episodes are now free!

Learn more or hide this

Emil Tin's Profile

GitHub User: emiltin

Site: http://tin.dk

Comments by Emil Tin

Avatar

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.

Avatar

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.

file bb.js.coffee:

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

$(document).ready ->
  Bb.init()

file entries_router.js.cofee:

class Bb.Routers.Entries extends Backbone.Router
        routes:
                '': '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 (0.9.1.0)
rails (3.2.1)
coffee-rails (3.2.2)