rails and backbone working together

前端 未结 3 708
离开以前
离开以前 2020-11-30 22:25

I am just starting to look at MVC structure, first i looked at how backbone.js worked, and now I have just completed rails for zombies, by Code School. I know t

3条回答
  •  鱼传尺愫
    2020-11-30 23:08

    I've used rails as a backend server to serve a fairly large website, which included a few one-page apps (built in backbone).

    I'd suggest the backbone-on-rails gem. The idea is that your rails server will serve up the backbone app as a script tag in one of your views. You keep your backbone app itself in the rails app/assets folder.

    Backbone understands rails routing conventions, and you just need to give it a path to a json api that rails can almost generate for you with rails generate resource.

    Other than the syncing between the models, your backbone apps and rails apps are fairly separate. Backbone and Rails don't have quite the same MVC model, but getting them to cooperate is pretty easy.

提交回复
热议问题