Reputation: 50057
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:
app/sproutcore
, and is still a bit unclear to me how that actually hooks in completely.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?
Upvotes: 4
Views: 1056
Reputation: 50057
I did find a demo-project: sproutcore-on-rails that did manage to make things clearer for me.
Upvotes: 0
Reputation: 2923
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
Upvotes: 1