good example applications combining rails 3 and sproutcore

随声附和 提交于 2019-12-20 15:11:51

问题


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/sproutcore, 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?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/7549114/good-example-applications-combining-rails-3-and-sproutcore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!