Reputation: 33
I'm trying to learn how to integrate Backbone.js with Ruby on Rails. I'm using the rails-backbone gem and have followed the example given at the bottom of the readme to scaffold a simple application so I can study the code.
When I run the server, my index page shows up with a list of objects from my database (I created a few test objects through the console) like it should, but none of the links work. The address changes, adding # and the rest of the url, but nothing on the page changes.
It seems to me that the backbone.js router isn't recognizing the hash change. I'm using Rails 3.2.2 Any advice?
Thanks!
Upvotes: 1
Views: 1140
Reputation: 2294
It seems there was an update to Backbone recently where routes won't match that are prefixed with a /
. So in your posts_router.js.coffee
file that the tutorial eventually has you generate, change:
routes:
"/new" : "newPost"
"/index" : "index"
"/:id/edit" : "edit"
"/:id" : "show"
".*" : "index"
to:
routes:
"new" : "newPost"
"index" : "index"
":id/edit" : "edit"
":id" : "show"
".*" : "index"
Hope this helps you.
Upvotes: 1