meleyal / backbone-on-rails

A simple gem for using Backbone.js with Rails.
MIT License
806 stars 125 forks source link

Backbone-on-rails demo app #18

Closed mulderp closed 12 years ago

mulderp commented 12 years ago

Hello,

this is not really an issue, but more a request or idea to make learning to use backbone easier. E.g. as I am starting to play with the gem, I am having a bit of a problem to understand how to combine multiple collections and views for a simple one-page application, and how to serve and process the json data in rails in the background.

I was thinking that a demo application for a blog could be a nice help to get started with the gem. I have created a small backbone-based-blog template here: https://github.com/mulderp/backbone_testapp

What do you think? Would it be helpful for other to gather feedback on the usage of backbone and rails?

meleyal commented 12 years ago

Hi Patrick,

There are already some good resources that might answer your questions.

The gem itself is based on the Backbone.js on Rails book from thoughtbot, which I can recommend: https://workshops.thoughtbot.com/backbone-js-on-rails

And a couple of Railscasts which cover building a single page app with the gem: http://railscasts.com/episodes/323-backbone-on-rails-part-1 http://railscasts.com/episodes/325-backbone-on-rails-part-2

Rather than a blog, I think the canonical example is the Todo app: http://documentcloud.github.com/backbone/docs/todos.html https://github.com/addyosmani/todomvc

I could definitely see the value of a step-by-step tutorial on how to build the example Todo app using the gem.

What do you think?

mulderp commented 12 years ago

Hi William,

thanks for the feedback and interest in this! Always helpful to get someone else's view.

From the links above, I know about the Ryan Bates's Railscasts, which are an excellent introduction to BackboneJS indeed (certainly in combination with Rails and Coffeescript)

I saw the Thoughtbot book yesterday, but need to delve into it still. There are also screencasts on Peepcode and good screencasts by @joeybeninghove http://backbonescreencasts.com/

The problem with these screencasts I had so far, that in my view, there are some shortcuts taken for didactical purposes (e.g. such as no CoffeeScript use, Sinatra backend, rather "simple" init and callback setups)

For my setup (in a Rails context), a blog application with nested resources (posts and comments), simple form updates, would be very helpful. What I did so far, was take the insights from Railscasts #323, and adapt these to a blog setup. I got stuck with posting comments to a post, and update the views and Rails models accordingly. I was planning to practice a bit more with the screencasts I have.

Hmm... I also will look into the todomvc, the nested resource setup might be a "project has_many todos".

What do you think on the usage of nested resources? What would be better in your view for a demo app, the TodoMVC projects/tasks or a Blog with Posts/comments?

meleyal commented 12 years ago

I just checked the thoughtbot book and it covers associations and nested resources (comments, attachments). It covers a lot of stuff such as this that you'd otherwise have to figure out through trial and error, so give it a look.

For the demo, I think a Todo app would be a better fit, as it's probably a more realistic use case for Backbone.

mulderp commented 12 years ago

Ok, thanks, just getting the book now (I had a preview up to now, and did not spot nested resources quickly).

So far, my discoveries were in the realm of using underscore and coffee/JS syntax. Coming from a console background, the interaction with the Firebug-console was also a nice discovery to debug the application code. All in all I make progress, and keep some notes. As soon as I have a first write-up, I let you know.

mulderp commented 12 years ago

Last weekend, I made a bit of progress with a demo Todo app:

https://github.com/mulderp/Backbone-on-Rails-todoDemo

And, I am doing some first write up right now:

http://pmulder.blogspot.de/2012/04/small-tutorial-to-using-backbonejs-with.html#links

What suggestions do you have to make it better and well accessible? thanks!

mulderp commented 12 years ago

A nice demo todo app based on the backbone-on-rails gem is here: https://github.com/addyosmani/backbone-boilerplates (Option 6)

meleyal commented 12 years ago

Hey Patrick, nice writeup and good start on the app. To take it further I would probably fork the addyosmani example you mentioned and re-implement it using the backbone-on-rails gem (currently it's using the backbone-rails gem).

mulderp commented 12 years ago

Hey there, I just finished the adaption of addyosmani's example and sent a pull request. The backbone-on-rails version is here: https://github.com/mulderp/backbone-boilerplates/commits/backbone-on-rails