codebrew / backbone-rails

Easily use backbone.js with rails 3.1
MIT License
1.62k stars 255 forks source link

names with multiple words doesn't seems to work #117

Open gouthamvel opened 12 years ago

gouthamvel commented 12 years ago

rails g backbone:scaffold StoreItems title:string content:string

index_view.js:27Uncaught TypeError: Cannot call method 'bind' of undefined

rylwin commented 12 years ago

I had this exact same issue (just took me 30min to debug it, just getting around to playing w/ backbone!). It's due to an inconsistency of the name conversion (i.e., you sometimes see store_items and sometime storeItems in the js). This leads to an undefined error.

I also think I ran across a similar issue with namespaces (e.g, Namespace::ObjectName). I got inconsistent naming across the backbone classes generated by the scaffold, but I need to research this a bit more.

Is anyone currently working on these issues?

wuliwong commented 11 years ago

I just encountered this same problem. I put it up on StackOverflow. http://stackoverflow.com/questions/13204368/rails-backbone-gem-error-for-model-with-two-word-names-uncaught-typeerror-cann#comment17979301_13204368

Essentially you just have to do a find and replace and change every 'storeItems' to 'store_items'. I would assume the find and replace the other direction would work as well, I just did it the way I mentioned. I'm not sure which choice would be better.

This issue should get labeled a bug, right?

westonplatter commented 10 years ago

@wuliwong cc/ @rylwin @gouthamvel

I think this would be an issue. I started a different repo (http://westonplatter.com/railsy_backbone) that mimics this repo, but has updated Backbone and Underscore. I'd also like to have JS testing around jquery-rails and Backbone integration.

I'll confirm if the described issue exists in http://westonplatter.com/railsy_backbone, and if issue is there there, fix it. :). Happy to work other PRs through the system.