开发者

good example applications combining rails 3 and sproutcore

I am trying to write a sproutcore frontend for a rails 3.1 application I am making. I have had a look at the sproutcore guides, but I am interested in seeing real examples how to use sproutcore together with rails 3(.1).

I have found two examples, but each is totally different:

  1. A todo-app created using bulk_api: an interesting approach using a specific REST-style to minimise the traffic. But it proposes to place the sproutcore app in app/sproutc开发者_StackOverflow社区ore, and is still a bit unclear to me how that actually hooks in completely.
  2. Travis-ci which seems to be a very clean example, rails 3.1, to use sproutcore. It is not yet completely clear to me, but all sproutcore js is cleanly stored inside app/assets/javascript/apps and as far as i can tell, the application.html just loads the js and provides the frame where everything is loaded into.

Do you know any other examples? How do you use sproutcore in your rails app?


The method you describe is the same way that you integrate backbone.js into a rails app, and it seems to work very well

https://github.com/codebrew/backbone-rails

This stores backbone in

app/assets/javascripts/backbone/
app/assets/javascripts/backbone/app/models
app/assets/javascripts/backbone/app/controllers

And then there is a script tag in the view that just initializes backbone

<script type="text/javascript">
  $(function() {
    // Blog is the app name
    window.router = new Blog.Routers.PostsRouter({posts: <%= @posts.to_json.html_safe -%>});
    Backbone.history.start();
  });
</script>

I imagine a similar process for sproutcore would make sense


I did find a demo-project: sproutcore-on-rails that did manage to make things clearer for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜