You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These [awesome people](https://github.com/codebrew/backbone-rails/graphs/contributors) helped to keep this gem updated
31
31
32
32
## Rails setup
33
33
This gem requires the use of rails 3.1 and greater, coffeescript and the new rails asset pipeline provided by sprockets.
34
34
35
-
This gem vendors the latest version of underscore.js and backbone.js for Rails 3.1 and greater. The files will be added to the asset pipeline and available for you to use.
36
-
35
+
This gem vendors the latest version of underscore.js and backbone.js for Rails 3.1 and greater. The files will be added to the asset pipeline and available for you to use.
36
+
37
37
### Installation
38
38
39
39
In your Gemfile, add this line:
40
40
41
41
gem "rails-backbone"
42
-
42
+
43
43
Then run the following commands:
44
44
45
45
bundle install
@@ -48,34 +48,34 @@ Then run the following commands:
48
48
### Layout and namespacing
49
49
50
50
Running `rails g backbone:install` will create the following directory structure under `app/assets/javascripts/backbone`:
51
-
51
+
52
52
routers/
53
53
models/
54
54
templates/
55
55
views/
56
-
56
+
57
57
It will also create a toplevel app_name.coffee file to setup namespacing and setup initial requires.
58
-
58
+
59
59
## Generators
60
-
backbone-rails provides 3 simple generators to help get you started using backbone.js with rails 3.1 and greater.
60
+
backbone-rails provides 3 simple generators to help get you started using backbone.js with rails 3.1 and greater.
61
61
The generators will only create client side code (javascript).
62
62
63
63
### Model Generator
64
64
65
65
rails g backbone:model model_name [property_name:property_type[,]]
66
-
66
+
67
67
This generator creates a backbone model and collection inside `app/assets/javascript/backbone/models` to be used to talk to the rails backend.
68
68
69
69
### Routers
70
-
70
+
71
71
rails g backbone:router model_name [action_name[,]]
72
-
72
+
73
73
This generator creates a backbone router with corresponding views and templates for the given actions provided.
74
74
75
75
### Scaffolding
76
76
77
77
rails g backbone:scaffold model_name [property_name:property_type[,]]
78
-
78
+
79
79
This generator creates a router, views, templates, model and collection to create a simple crud single page app
80
80
81
81
## Example Usage
@@ -95,8 +95,8 @@ Install the gem and generate scaffolding.
95
95
rails g scaffold Post title:string content:string
96
96
rake db:migrate
97
97
rails g backbone:scaffold Post title:string content:string
98
-
99
-
You now have installed the backbone-rails gem, setup a default directory structure for your frontend backbone code.
98
+
99
+
You now have installed the backbone-rails gem, setup a default directory structure for your frontend backbone code.
100
100
Then you generated the usual rails server side crud scaffolding and finally generated backbone.js code to provide a simple single page crud app.
101
101
You have one last step:
102
102
@@ -111,11 +111,11 @@ Edit your posts index view `app/views/posts/index.html.erb` with the following c
111
111
Backbone.history.start();
112
112
});
113
113
</script>
114
-
114
+
115
115
If you prefer haml, this is equivalent to inserting the following code into `app/views/posts/index.html.haml`:
116
116
117
117
#posts
118
-
118
+
119
119
:javascript
120
120
$(function() {
121
121
// Blog is the app name
@@ -145,4 +145,3 @@ Change it to add `id` attribute as well
0 commit comments