ember-rails 0.15.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +103 -58
- data/lib/ember/handlebars/template.rb +1 -1
- data/lib/ember/rails/version.rb +1 -1
- data/lib/ember_rails.rb +11 -3
- data/lib/generators/ember/install_generator.rb +19 -8
- data/lib/generators/ember/resource_override.rb +8 -2
- data/lib/generators/templates/app.js +1 -1
- data/lib/generators/templates/app.js.coffee +1 -0
- data/lib/generators/templates/app.js.em +2 -0
- data/lib/generators/templates/application.js.em +1 -0
- data/lib/generators/templates/model.js +1 -1
- data/lib/generators/templates/model.js.coffee +1 -1
- data/lib/generators/templates/model.js.em +1 -1
- data/lib/generators/templates/store.js +11 -4
- data/lib/generators/templates/store.js.coffee +9 -4
- data/lib/generators/templates/store.js.em +9 -2
- metadata +5 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3d46472d346a709f8580fb4050457cc583d25c02
|
|
4
|
+
data.tar.gz: 584df87b5a4286f252d6358856d11893af17caa0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ff21e550943f708355597fcc7ef9bc51661b5680199e0c1cdfbb7c497bcd062210194f301795ee438ec95a8dc0c74b1ffd0c378f8a298a88974c358a4285d98e
|
|
7
|
+
data.tar.gz: 77c10beb5d970e42b94cd6138a0860835182d9e01334e10d07c20e40148229aa5e8b65d747026c8d09b8c248a8b4b0ce5e81dc9c34fd9268d262b18ea2cb8c19
|
data/README.md
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
# ember-rails [](http://travis-ci.org/emberjs/ember-rails) [](https://gemnasium.com/emberjs/ember-rails)
|
|
2
2
|
|
|
3
3
|
ember-rails makes developing an [Ember.JS](http://emberjs.com/) application much easier in Rails 3.1+.
|
|
4
4
|
|
|
5
5
|
The following functionalities are included in this gem:
|
|
6
6
|
- Pre-compiling of your handlebars templates when building your asset pipeline.
|
|
7
|
-
-
|
|
8
|
-
-
|
|
7
|
+
- Inclusion of development and production copies of Ember, [Ember Data](https://github.com/emberjs/data) and [Handlebars](https://github.com/wycats/handlebars.js).
|
|
8
|
+
- Inclusion of [ActiveModel::Serializer](https://github.com/rails-api/active_model_serializers) for integration with Ember Data.
|
|
9
9
|
|
|
10
|
-
You can see an example of how to use the gem [here](https://github.com/keithpitt/ember-rails-example). There is also a great tutorial by [Dan Gebhardt](https://twitter.com/#!/dgeb) called "[Beginning Ember.js on Rails](http://www.cerebris.com/blog/2012/01/24/beginning-ember-js-on-rails-part-1/)" which is a great read if you're just starting out with Rails and Ember.js
|
|
10
|
+
You can see an example of how to use the gem [here](https://github.com/keithpitt/ember-rails-example). There is also a great tutorial by [Dan Gebhardt](https://twitter.com/#!/dgeb) called "[Beginning Ember.js on Rails](http://www.cerebris.com/blog/2012/01/24/beginning-ember-js-on-rails-part-1/)" which is a great read if you're just starting out with Rails and Ember.js.
|
|
11
11
|
|
|
12
12
|
## Getting started
|
|
13
13
|
* Add the gem to your application Gemfile:
|
|
14
14
|
|
|
15
15
|
```ruby
|
|
16
16
|
gem 'ember-rails'
|
|
17
|
-
gem 'ember-source', '1.
|
|
17
|
+
gem 'ember-source', '~> 1.9.0' # or the version you need
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
* Run `bundle install`
|
|
@@ -54,29 +54,28 @@ You'll probably need to clear out your cache after doing this with:
|
|
|
54
54
|
rake tmp:clear
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
+
Also, ember-rails include some flags for the bootstrap generator:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
--ember-path or -d # custom ember path
|
|
61
|
+
--skip-git or -g # skip git keeps
|
|
62
|
+
--javascript-engine # engine for javascript (js, coffee or em)
|
|
63
|
+
--app-name or -n # custom ember app name
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
|
|
57
67
|
## For CoffeeScript support
|
|
58
68
|
|
|
59
|
-
|
|
69
|
+
Add coffee-rails to the Gemfile
|
|
60
70
|
```ruby
|
|
61
71
|
gem 'coffee-rails'
|
|
62
72
|
```
|
|
63
73
|
|
|
64
|
-
|
|
74
|
+
Run the bootstrap generator in step 4 with an extra flag instead:
|
|
65
75
|
```sh
|
|
66
76
|
rails g ember:bootstrap -g --javascript-engine coffee
|
|
67
77
|
```
|
|
68
78
|
|
|
69
|
-
Note:
|
|
70
|
-
|
|
71
|
-
Ember-rails include some flags options for bootstrap generator:
|
|
72
|
-
|
|
73
|
-
```
|
|
74
|
-
--ember-path or -d # custom ember path
|
|
75
|
-
--skip-git or -g # skip git keeps
|
|
76
|
-
--javascript-engine # engine for javascript (js or coffee)
|
|
77
|
-
--app-name or -n # custom ember app name
|
|
78
|
-
```
|
|
79
|
-
|
|
80
79
|
## For EmberScript support
|
|
81
80
|
|
|
82
81
|
[EmberScript](http://www.emberscript.com) is a dialect of CoffeeScript
|
|
@@ -95,45 +94,87 @@ You can now use the flag `--javascript-engine=em` to specify EmberScript
|
|
|
95
94
|
assets in your generators, but all of the generators will default to
|
|
96
95
|
using an EmberScript variant first.
|
|
97
96
|
|
|
97
|
+
Note:
|
|
98
|
+
|
|
99
|
+
Ember-rails include some flags options for bootstrap generator:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
--ember-path or -d # custom ember path
|
|
103
|
+
--skip-git or -g # skip git keeps
|
|
104
|
+
--javascript-engine # engine for javascript (js, coffee or em)
|
|
105
|
+
--app-name or -n # custom ember app name
|
|
106
|
+
```
|
|
107
|
+
|
|
98
108
|
## Configuration Options
|
|
99
109
|
|
|
100
110
|
The following options are available for configuration in your application or environment-level
|
|
101
111
|
config files (`config/application.rb`, `config/environments/development.rb`, etc.):
|
|
102
112
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
113
|
+
| Configuration Option | Description |
|
|
114
|
+
|----------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
|
|
115
|
+
| `config.ember.variant` | Determines which Ember variant to use. Valid options: `:development`, `:production`. |
|
|
116
|
+
| `config.ember.app_name` | Specificies a default application name for all generators. |
|
|
117
|
+
| `config.ember.ember_path` | Specifies a default custom root path for all generators. |
|
|
118
|
+
| `config.handlebars.precompile` | Enables or disables precompilation. Default value: `true`. |
|
|
119
|
+
| `config.handlebars.templates_root` | Sets the root path (under `app/assets/javascripts`) for templates to be looked up in. Default value: `"templates"`. |
|
|
120
|
+
| `config.handlebars.templates_path_separator` | The path separator to use for templates. Default value: `'/'`. |
|
|
121
|
+
| `config.handlebars.output_type` | Configures the style of output (options are `:amd` and `:global`). Default value: `:global`. |
|
|
122
|
+
|
|
123
|
+
Note:
|
|
124
|
+
|
|
125
|
+
In a mountable engine, ember-rails will not recognize any configurations.
|
|
126
|
+
Instead, use command line options.
|
|
127
|
+
|
|
128
|
+
## Enabling Features with Feature Flags
|
|
129
|
+
See [the guide](http://emberjs.com/guides/configuring-ember/feature-flags/#toc_flagging-details) and check [features.json](https://github.com/emberjs/ember.js/blob/master/features.json) for the version of Ember you're using.
|
|
130
|
+
|
|
131
|
+
If a feature is set to false, you will need to compile ember from source yourself to include it.
|
|
132
|
+
|
|
133
|
+
### Important note for projects that render JSON responses
|
|
134
|
+
|
|
135
|
+
ember-rails includes [active_model_serializers](https://github.com/rails-api/active_model_serializers) which affects how ActiveModel and ActiveRecord objects get serialized to JSON, such as when using `render json:` or `respond_with`. By default active_model_serializers adds root elements to these responses (such as adding `{"posts": [...]}` for `render json: @posts`) which will affect the structure of your JSON responses.
|
|
136
|
+
|
|
137
|
+
To disable this effect on your JSON responses, put this in an initializer:
|
|
138
|
+
```Ruby
|
|
139
|
+
# Stop active_model_serializers from adding root elements to JSON responses.
|
|
140
|
+
ActiveModel::Serializer.root = false
|
|
141
|
+
ActiveModel::ArraySerializer.root = false
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
See the [active_model_serializers](https://github.com/rails-api/active_model_serializers) documentation for a more complete understanding of other effects this dependency might have on your app.
|
|
112
145
|
|
|
113
146
|
## Architecture
|
|
114
147
|
|
|
115
148
|
Ember does not require an organized file structure. However, ember-rails allows you
|
|
116
149
|
to use `rails g ember:bootstrap` to create the following directory structure under `app/assets/javascripts`:
|
|
117
150
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
151
|
+
```
|
|
152
|
+
├── components
|
|
153
|
+
├── controllers
|
|
154
|
+
├── helpers
|
|
155
|
+
├── mixins
|
|
156
|
+
├── models
|
|
157
|
+
├── practicality.js.coffee
|
|
158
|
+
├── router.js.coffee
|
|
159
|
+
├── routes
|
|
160
|
+
├── store.js.coffee
|
|
161
|
+
├── templates
|
|
162
|
+
│ └── components
|
|
163
|
+
└── views
|
|
164
|
+
```
|
|
126
165
|
|
|
127
166
|
Additionally, it will add the following lines to `app/assets/javascripts/application.js`.
|
|
128
167
|
By default, it uses the Rails Application's name and creates an `rails_app_name.js`
|
|
129
168
|
file to set up application namespace and initial requires:
|
|
130
169
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
170
|
+
```javascript
|
|
171
|
+
//= require handlebars
|
|
172
|
+
//= require ember
|
|
173
|
+
//= require ember-data
|
|
174
|
+
//= require_self
|
|
175
|
+
//= require rails_app_name
|
|
176
|
+
RailsAppName = Ember.Application.create();
|
|
177
|
+
```
|
|
137
178
|
|
|
138
179
|
*Example:*
|
|
139
180
|
|
|
@@ -165,8 +206,7 @@ and including the assets in your layout:
|
|
|
165
206
|
|
|
166
207
|
<%= javascript_include_tag "templates/admin_panel" %>
|
|
167
208
|
|
|
168
|
-
If you want to
|
|
169
|
-
By default, `templates_root` is `'templates'`.
|
|
209
|
+
If you want to avoid the `templates` prefix, set the `templates_root` option in your application configuration block:
|
|
170
210
|
|
|
171
211
|
config.handlebars.templates_root = 'ember_templates'
|
|
172
212
|
|
|
@@ -191,7 +231,7 @@ Now a single line in the layout loads everything:
|
|
|
191
231
|
|
|
192
232
|
<%= javascript_include_tag "templates/all" %>
|
|
193
233
|
|
|
194
|
-
If you use Slim or Haml templates, you can use handlebars filter :
|
|
234
|
+
If you use Slim or Haml templates, you can use the handlebars filter :
|
|
195
235
|
|
|
196
236
|
handlebars:
|
|
197
237
|
<button {{action anActionName}}>OK</button>
|
|
@@ -208,23 +248,29 @@ When necessary, ember-rails adheres to a conventional folder structure. To creat
|
|
|
208
248
|
|
|
209
249
|
*Example*
|
|
210
250
|
|
|
211
|
-
|
|
251
|
+
Given the following folder structure:
|
|
212
252
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
253
|
+
```
|
|
254
|
+
├── components
|
|
255
|
+
├── controllers
|
|
256
|
+
├── helpers
|
|
257
|
+
├── mixins
|
|
258
|
+
├── models
|
|
259
|
+
├── practicality.js.coffee
|
|
260
|
+
├── router.js.coffee
|
|
261
|
+
├── routes
|
|
262
|
+
├── store.js.coffee
|
|
263
|
+
├── templates
|
|
264
|
+
│ └── components
|
|
265
|
+
│ └── my-component.handlebars
|
|
266
|
+
└── views
|
|
267
|
+
```
|
|
222
268
|
|
|
223
|
-
and a
|
|
269
|
+
and a `my-component.handlebars` file with the following contents:
|
|
224
270
|
|
|
225
271
|
<h1>My Component</h1>
|
|
226
272
|
|
|
227
|
-
will produce the following handlebars output
|
|
273
|
+
It will produce the following handlebars output:
|
|
228
274
|
|
|
229
275
|
<script type="text/x-handlebars" id="components/my-component">
|
|
230
276
|
<h1>My Component</h1>
|
|
@@ -260,7 +306,6 @@ RailsAppName.js.coffee
|
|
|
260
306
|
|
|
261
307
|
These are automatically generated for you in new projects you when you run the `ember:bootstrap` generator.
|
|
262
308
|
|
|
263
|
-
|
|
264
309
|
## Specifying Different Versions of Ember/Handlebars/Ember-Data
|
|
265
310
|
|
|
266
311
|
By default, ember-rails ships with the latest version of
|
|
@@ -272,7 +317,7 @@ To specify a different version that'll be used for both template
|
|
|
272
317
|
precompilation and serving to the browser, you can specify the desired
|
|
273
318
|
version of one of the above-linked gems in the Gemfile, e.g.:
|
|
274
319
|
|
|
275
|
-
gem 'ember-source', '1.
|
|
320
|
+
gem 'ember-source', '1.7.0'
|
|
276
321
|
|
|
277
322
|
You can also specify versions of 'handlebars-source' and
|
|
278
323
|
'ember-data-source', but note that an appropriate 'handlebars-source'
|
|
@@ -37,7 +37,7 @@ module Ember
|
|
|
37
37
|
if configuration.output_type == :amd
|
|
38
38
|
target = amd_template_target(scope)
|
|
39
39
|
|
|
40
|
-
"define('#{target}', ['exports'], function(__exports__){ __exports__
|
|
40
|
+
"define('#{target}', ['exports'], function(__exports__){ __exports__['default'] = #{template} });"
|
|
41
41
|
else
|
|
42
42
|
target = global_template_target(scope)
|
|
43
43
|
|
data/lib/ember/rails/version.rb
CHANGED
data/lib/ember_rails.rb
CHANGED
|
@@ -26,10 +26,18 @@ module Ember
|
|
|
26
26
|
# Copy over the desired ember, ember-data, and handlebars bundled in
|
|
27
27
|
# ember-source, ember-data-source, and handlebars-source to a tmp folder.
|
|
28
28
|
tmp_path = app.root.join("tmp/ember-rails")
|
|
29
|
-
ext = variant == :production ? ".prod.js" : ".js"
|
|
30
29
|
FileUtils.mkdir_p(tmp_path)
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
|
|
31
|
+
if variant == :production
|
|
32
|
+
ember_ext = ".prod.js"
|
|
33
|
+
else
|
|
34
|
+
ember_ext = ".debug.js"
|
|
35
|
+
ember_ext = ".js" unless File.exist?(::Ember::Source.bundled_path_for("ember#{ember_ext}")) # Ember.js 1.9.0 or earlier has no "ember.debug.js"
|
|
36
|
+
end
|
|
37
|
+
FileUtils.cp(::Ember::Source.bundled_path_for("ember#{ember_ext}"), tmp_path.join("ember.js"))
|
|
38
|
+
ember_data_ext = variant == :production ? ".prod.js" : ".js"
|
|
39
|
+
FileUtils.cp(::Ember::Data::Source.bundled_path_for("ember-data#{ember_data_ext}"), tmp_path.join("ember-data.js"))
|
|
40
|
+
|
|
33
41
|
app.assets.append_path(tmp_path)
|
|
34
42
|
|
|
35
43
|
# Make the handlebars.js and handlebars.runtime.js bundled
|
|
@@ -73,35 +73,40 @@ module Ember
|
|
|
73
73
|
|
|
74
74
|
private
|
|
75
75
|
|
|
76
|
-
|
|
77
76
|
def get_ember_data_for(environment)
|
|
78
77
|
# temporarily using a variable here until a stable release of
|
|
79
78
|
# ember-data is released so that installing with ember-data
|
|
80
79
|
# *just works*.
|
|
81
|
-
chan = if channel ==
|
|
80
|
+
chan = if channel.to_s == 'release'
|
|
82
81
|
say_status("warning:", 'Ember Data is not available on the :release channel. Falling back to beta channel.' , :yellow)
|
|
83
82
|
:beta
|
|
84
83
|
else
|
|
85
84
|
channel
|
|
86
85
|
end
|
|
86
|
+
|
|
87
87
|
create_file "vendor/assets/ember/#{environment}/ember-data.js" do
|
|
88
|
-
fetch
|
|
88
|
+
fetch url_for(chan, 'ember-data', environment), "vendor/assets/ember/#{environment}/ember-data.js"
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
def get_ember_js_for(environment)
|
|
93
|
-
|
|
94
93
|
create_file "vendor/assets/ember/#{environment}/ember.js" do
|
|
95
|
-
fetch
|
|
94
|
+
fetch url_for(channel, 'ember', environment), "vendor/assets/ember/#{environment}/ember.js"
|
|
96
95
|
end
|
|
97
96
|
end
|
|
98
97
|
|
|
99
|
-
def
|
|
98
|
+
def url_for(channel, component, environment)
|
|
99
|
+
base = "#{base_url}/#{channel}/#{component}"
|
|
100
|
+
|
|
100
101
|
case environment
|
|
101
102
|
when :production
|
|
102
|
-
"#{
|
|
103
|
+
"#{base}.min.js"
|
|
103
104
|
when :development
|
|
104
|
-
"#{
|
|
105
|
+
if resource_exist?("#{base}.debug.js")
|
|
106
|
+
"#{base}.debug.js" # Ember.js 1.10.0.beta.1 or later
|
|
107
|
+
else
|
|
108
|
+
"#{base}.js"
|
|
109
|
+
end
|
|
105
110
|
end
|
|
106
111
|
end
|
|
107
112
|
|
|
@@ -174,6 +179,12 @@ module Ember
|
|
|
174
179
|
output.rewind
|
|
175
180
|
content = output.read
|
|
176
181
|
end
|
|
182
|
+
|
|
183
|
+
def resource_exist?(target)
|
|
184
|
+
uri = URI(target)
|
|
185
|
+
response = Net::HTTP.new(uri.host, uri.port).head(uri.path)
|
|
186
|
+
response.code == '200'
|
|
187
|
+
end
|
|
177
188
|
end
|
|
178
189
|
end
|
|
179
190
|
end
|
|
@@ -6,6 +6,12 @@ require "generators/ember/view_generator"
|
|
|
6
6
|
module Rails
|
|
7
7
|
module Generators
|
|
8
8
|
ResourceGenerator.class_eval do
|
|
9
|
+
|
|
10
|
+
class_option :javascript_engine, :desc => "Engine for JavaScripts"
|
|
11
|
+
class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
|
|
12
|
+
class_option :with_template, :type => :boolean, :default => false, :desc => "Create template for this view"
|
|
13
|
+
class_option :app_name, :type => :string, :aliases => "-n", :default => false, :desc => "Custom ember app name"
|
|
14
|
+
|
|
9
15
|
def add_ember
|
|
10
16
|
say_status :invoke, "ember:model", :white
|
|
11
17
|
with_padding do
|
|
@@ -14,7 +20,7 @@ module Rails
|
|
|
14
20
|
|
|
15
21
|
say_status :invoke, "ember controller and view (singular)", :white
|
|
16
22
|
with_padding do
|
|
17
|
-
invoke "ember:view", [singular_name], :object => true
|
|
23
|
+
invoke "ember:view", [singular_name], options.merge(:object => true)
|
|
18
24
|
end
|
|
19
25
|
|
|
20
26
|
@_invocations[Ember::Generators::ControllerGenerator].delete "create_controller_files"
|
|
@@ -22,7 +28,7 @@ module Rails
|
|
|
22
28
|
|
|
23
29
|
say_status :invoke, "ember controller and view (plural)", :white
|
|
24
30
|
with_padding do
|
|
25
|
-
invoke "ember:view", [plural_name], :array => true
|
|
31
|
+
invoke "ember:view", [plural_name], options.merge(:array => true)
|
|
26
32
|
end
|
|
27
33
|
end
|
|
28
34
|
end
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
#= require ./store
|
|
2
|
+
#= require_tree ./mixins
|
|
2
3
|
#= require_tree ./models
|
|
3
4
|
#= require_tree ./controllers
|
|
4
5
|
#= require_tree ./views
|
|
5
6
|
#= require_tree ./helpers
|
|
7
|
+
#= require_tree ./components
|
|
6
8
|
#= require_tree ./templates
|
|
7
9
|
#= require_tree ./routes
|
|
8
10
|
#= require ./router
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<% attributes.each_with_index do |attribute, idx| -%>
|
|
5
5
|
<%= attribute[:name].camelize(:lower) %>: <%=
|
|
6
6
|
if %w(references belongs_to).member?(attribute[:type])
|
|
7
|
-
"DS.belongsTo('%s
|
|
7
|
+
"DS.belongsTo('%s')" % attribute[:name].camelize(:lower)
|
|
8
8
|
else
|
|
9
9
|
"DS.attr('%s')" % attribute[:type]
|
|
10
10
|
end
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<% attributes.each do |attribute| -%>
|
|
5
5
|
<%= attribute[:name].camelize(:lower) %>: <%=
|
|
6
6
|
if %w(references belongs_to).member?(attribute[:type])
|
|
7
|
-
"DS.belongsTo '%s
|
|
7
|
+
"DS.belongsTo '%s'" % attribute[:name].camelize(:lower)
|
|
8
8
|
else
|
|
9
9
|
"DS.attr '%s'" % attribute[:type]
|
|
10
10
|
end
|
|
@@ -4,7 +4,7 @@ class <%= application_name.camelize %>.<%= class_name %> extends DS.Model
|
|
|
4
4
|
<% attributes.each do |attribute| -%>
|
|
5
5
|
<%= attribute[:name].camelize(:lower) %>: <%=
|
|
6
6
|
if %w(references belongs_to).member?(attribute[:type])
|
|
7
|
-
"DS.belongsTo '%s
|
|
7
|
+
"DS.belongsTo '%s'" % attribute[:name].camelize(:lower)
|
|
8
8
|
else
|
|
9
9
|
"DS.attr '%s'" % attribute[:type]
|
|
10
10
|
end
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
<%= application_name.camelize %>.Store = DS.Store.extend({
|
|
2
|
-
|
|
3
|
-
});
|
|
4
|
-
|
|
5
1
|
// Override the default adapter with the `DS.ActiveModelAdapter` which
|
|
6
2
|
// is built to work nicely with the ActiveModel::Serializers gem.
|
|
7
3
|
<%= application_name.camelize %>.ApplicationAdapter = DS.ActiveModelAdapter.extend({
|
|
8
4
|
|
|
9
5
|
});
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// Adds X-CSRF-Token to all REST requests.
|
|
9
|
+
// Allows for the use of Rails protect_from_forgery
|
|
10
|
+
// The CSRF Token is normally found in app/views/layouts/application.html.*
|
|
11
|
+
// inserted with the rails helper: "csrf_meta_tags"
|
|
12
|
+
DS.RESTAdapter.reopen({
|
|
13
|
+
headers: {
|
|
14
|
+
"X-CSRF-Token": $('meta[name="csrf-token"]').attr('content')
|
|
15
|
+
}
|
|
16
|
+
});
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
# http://emberjs.com/guides/models/#toc_store
|
|
2
2
|
# http://emberjs.com/guides/models/pushing-records-into-the-store/
|
|
3
3
|
|
|
4
|
-
<%= application_name.camelize %>.Store = DS.Store.extend({
|
|
5
|
-
|
|
6
|
-
})
|
|
7
|
-
|
|
8
4
|
# Override the default adapter with the `DS.ActiveModelAdapter` which
|
|
9
5
|
# is built to work nicely with the ActiveModel::Serializers gem.
|
|
10
6
|
<%= application_name.camelize %>.ApplicationAdapter = DS.ActiveModelAdapter.extend({
|
|
11
7
|
|
|
12
8
|
})
|
|
9
|
+
|
|
10
|
+
# Adds X-CSRF-Token to all REST requests.
|
|
11
|
+
# Allows for the use of Rails protect_from_forgery
|
|
12
|
+
# The CSRF Token is normally found in app/views/layouts/application.html.*
|
|
13
|
+
# inserted with the rails helper: "csrf_meta_tags"
|
|
14
|
+
DS.RESTAdapter.reopen(
|
|
15
|
+
headers:
|
|
16
|
+
"X-CSRF-Token": $('meta[name="csrf-token"]').attr('content')
|
|
17
|
+
)
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
class <%= application_name.camelize %>.Store extends DS.Store
|
|
2
|
-
|
|
3
1
|
# Override the default adapter with the `DS.ActiveModelAdapter` which
|
|
4
2
|
# is built to work nicely with the ActiveModel::Serializers gem.
|
|
5
3
|
class <%= application_name.camelize %>.ApplicationAdapter extends DS.ActiveModelAdapter
|
|
4
|
+
|
|
5
|
+
# Adds X-CSRF-Token to all REST requests.
|
|
6
|
+
# Allows for the use of Rails protect_from_forgery
|
|
7
|
+
# The CSRF Token is normally found in app/views/layouts/application.html.*
|
|
8
|
+
# inserted with the rails helper: "csrf_meta_tags"
|
|
9
|
+
DS.RESTAdapter.reopen(
|
|
10
|
+
headers:
|
|
11
|
+
"X-CSRF-Token": $('meta[name="csrf-token"]').attr('content')
|
|
12
|
+
)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ember-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.15.
|
|
4
|
+
version: 0.15.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Keith Pitt
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date: 2014-
|
|
14
|
+
date: 2014-12-13 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: execjs
|
|
@@ -145,14 +145,14 @@ dependencies:
|
|
|
145
145
|
requirements:
|
|
146
146
|
- - ">="
|
|
147
147
|
- !ruby/object:Gem::Version
|
|
148
|
-
version:
|
|
148
|
+
version: 1.0.0
|
|
149
149
|
type: :development
|
|
150
150
|
prerelease: false
|
|
151
151
|
version_requirements: !ruby/object:Gem::Requirement
|
|
152
152
|
requirements:
|
|
153
153
|
- - ">="
|
|
154
154
|
- !ruby/object:Gem::Version
|
|
155
|
-
version:
|
|
155
|
+
version: 1.0.0
|
|
156
156
|
- !ruby/object:Gem::Dependency
|
|
157
157
|
name: tzinfo
|
|
158
158
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -290,9 +290,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
290
290
|
version: '0'
|
|
291
291
|
requirements: []
|
|
292
292
|
rubyforge_project:
|
|
293
|
-
rubygems_version: 2.
|
|
293
|
+
rubygems_version: 2.4.5
|
|
294
294
|
signing_key:
|
|
295
295
|
specification_version: 4
|
|
296
296
|
summary: Ember for Rails 3.1+
|
|
297
297
|
test_files: []
|
|
298
|
-
has_rdoc:
|