-
Notifications
You must be signed in to change notification settings - Fork 2
/
3_2_release_notes.html
807 lines (742 loc) · 46.8 KB
/
3_2_release_notes.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Ruby on Rails 3.2 Release Notes — Ruby on Rails 指南</title>
<link rel="stylesheet" type="text/css" href="stylesheets/style.css" />
<link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print" />
<link rel="stylesheet" type="text/css" href="stylesheets/syntaxhighlighter/shCore.css" />
<link rel="stylesheet" type="text/css" href="stylesheets/syntaxhighlighter/shThemeRailsGuides.css" />
<link rel="stylesheet" type="text/css" href="stylesheets/fixes.css" />
<link href="images/favicon.ico" rel="shortcut icon" type="image/x-icon" />
</head>
<body class="guide">
<div id="topNav">
<div class="wrapper">
<strong class="more-info-label">更多内容 <a href="http://rubyonrails.org/">rubyonrails.org:</a> </strong>
<span class="red-button more-info-button">
更多内容
</span>
<ul class="more-info-links s-hidden">
<li class="more-info"><a href="http://rubyonrails.org/">综览</a></li>
<li class="more-info"><a href="http://rubyonrails.org/download">下载</a></li>
<li class="more-info"><a href="http://rubyonrails.org/deploy">部署</a></li>
<li class="more-info"><a href="https://github.com/rails/rails">源码</a></li>
<li class="more-info"><a href="http://rubyonrails.org/screencasts">视频</a></li>
<li class="more-info"><a href="http://rubyonrails.org/documentation">文件</a></li>
<li class="more-info"><a href="http://rubyonrails.org/community">社群</a></li>
<li class="more-info"><a href="http://weblog.rubyonrails.org/">Blog</a></li>
</ul>
</div>
</div>
<div id="header">
<div class="wrapper clearfix">
<h1><a href="index.html" title="回首页">Guides.rubyonrails.org</a></h1>
<ul class="nav">
<li><a class="nav-item" href="index.html">首页</a></li>
<li class="guides-index guides-index-large">
<a href="index.html" id="guidesMenu" class="guides-index-item nav-item">指南目录</a>
<div id="guides" class="clearfix" style="display: none;">
<hr />
<dl class="L">
<dt>入门</dt>
<dd><a href="getting_started.html">Rails 入门</a></dd>
<dt>模型</dt>
<dd><a href="active_record_basics.html">Active Record 基础</a></dd>
<dd><a href="active_record_migrations.html">Active Record 数据库迁移</a></dd>
<dd><a href="active_record_validations.html">Active Record 数据验证</a></dd>
<dd><a href="active_record_callbacks.html">Active Record 回调</a></dd>
<dd><a href="association_basics.html">Active Record 关联</a></dd>
<dd><a href="active_record_querying.html">Active Record 查询</a></dd>
<dt>视图</dt>
<dd><a href="layouts_and_rendering.html">Rails 布局和视图渲染</a></dd>
<dd><a href="form_helpers.html">Action View 表单帮助方法</a></dd>
<dt>控制器</dt>
<dd><a href="action_controller_overview.html">Action Controller 简介</a></dd>
<dd><a href="routing.html">Rails 路由全解</a></dd>
</dl>
<dl class="R">
<dt>深入</dt>
<dd><a href="active_support_core_extensions.html">Active Support 核心扩展</a></dd>
<dd><a href="i18n.html">Rails 国际化 API</a></dd>
<dd><a href="action_mailer_basics.html">Action Mailer 基础</a></dd>
<dd><a href="active_job_basics.html">Active Job 基础</a></dd>
<dd><a href="security.html">Rails 安全指南</a></dd>
<dd><a href="debugging_rails_applications.html">调试 Rails 程序</a></dd>
<dd><a href="configuring.html">设置 Rails 程序</a></dd>
<dd><a href="command_line.html">Rails 命令行</a></dd>
<dd><a href="asset_pipeline.html">Asset Pipeline</a></dd>
<dd><a href="working_with_javascript_in_rails.html">在 Rails 中使用 JavaScript</a></dd>
<dd><a href="constant_autoloading_and_reloading.html">Constant Autoloading and Reloading</a></dd>
<dt>扩展 Rails</dt>
<dd><a href="rails_on_rack.html">Rails on Rack</a></dd>
<dd><a href="generators.html">客制与新建 Rails 产生器</a></dd>
<dd><a href="rails_application_templates.html">Rails 应用程式模版</a></dd>
<dt>贡献 Ruby on Rails</dt>
<dd><a href="contributing_to_ruby_on_rails.html">贡献 Ruby on Rails</a></dd>
<dd><a href="api_documentation_guidelines.html">API 文件准则</a></dd>
<dd><a href="ruby_on_rails_guides_guidelines.html">Ruby on Rails 指南准则</a></dd>
<dt>维护方针</dt>
<dd><a href="maintenance_policy.html">维护方针</a></dd>
<dt>发布记</dt>
<dd><a href="upgrading_ruby_on_rails.html">升级 Ruby on Rails</a></dd>
<dd><a href="4_2_release_notes.html">Ruby on Rails 4.2 发布记</a></dd>
<dd><a href="4_1_release_notes.html">Ruby on Rails 4.1 发布记</a></dd>
<dd><a href="4_0_release_notes.html">Ruby on Rails 4.0 发布记</a></dd>
<dd><a href="3_2_release_notes.html">Ruby on Rails 3.2 发布记</a></dd>
<dd><a href="3_1_release_notes.html">Ruby on Rails 3.1 发布记</a></dd>
<dd><a href="3_0_release_notes.html">Ruby on Rails 3.0 发布记</a></dd>
<dd><a href="2_3_release_notes.html">Ruby on Rails 2.3 发布记</a></dd>
<dd><a href="2_2_release_notes.html">Ruby on Rails 2.2 发布记</a></dd>
</dl>
</div>
</li>
<!-- <li><a class="nav-item" href="//github.com/docrails-tw/wiki">参与翻译</a></li> -->
<li><a class="nav-item" href="https://github.com/ruby-china/guides/blob/master/CONTRIBUTING.md">贡献</a></li>
<li><a class="nav-item" href="credits.html">致谢</a></li>
<li class="guides-index guides-index-small">
<select class="guides-index-item nav-item">
<option value="index.html">指南目录</option>
<optgroup label="入门">
<option value="getting_started.html">Rails 入门</option>
</optgroup>
<optgroup label="模型">
<option value="active_record_basics.html">Active Record 基础</option>
<option value="active_record_migrations.html">Active Record 数据库迁移</option>
<option value="active_record_validations.html">Active Record 数据验证</option>
<option value="active_record_callbacks.html">Active Record 回调</option>
<option value="association_basics.html">Active Record 关联</option>
<option value="active_record_querying.html">Active Record 查询</option>
</optgroup>
<optgroup label="视图">
<option value="layouts_and_rendering.html">Rails 布局和视图渲染</option>
<option value="form_helpers.html">Action View 表单帮助方法</option>
</optgroup>
<optgroup label="控制器">
<option value="action_controller_overview.html">Action Controller 简介</option>
<option value="routing.html">Rails 路由全解</option>
</optgroup>
<optgroup label="深入">
<option value="active_support_core_extensions.html">Active Support 核心扩展</option>
<option value="i18n.html">Rails 国际化 API</option>
<option value="action_mailer_basics.html">Action Mailer 基础</option>
<option value="active_job_basics.html">Active Job 基础</option>
<option value="security.html">Rails 安全指南</option>
<option value="debugging_rails_applications.html">调试 Rails 程序</option>
<option value="configuring.html">设置 Rails 程序</option>
<option value="command_line.html">Rails 命令行</option>
<option value="asset_pipeline.html">Asset Pipeline</option>
<option value="working_with_javascript_in_rails.html">在 Rails 中使用 JavaScript</option>
<option value="constant_autoloading_and_reloading.html">Constant Autoloading and Reloading</option>
</optgroup>
<optgroup label="扩展 Rails">
<option value="rails_on_rack.html">Rails on Rack</option>
<option value="generators.html">客制与新建 Rails 产生器</option>
<option value="rails_application_templates.html">Rails 应用程式模版</option>
</optgroup>
<optgroup label="贡献 Ruby on Rails">
<option value="contributing_to_ruby_on_rails.html">贡献 Ruby on Rails</option>
<option value="api_documentation_guidelines.html">API 文件准则</option>
<option value="ruby_on_rails_guides_guidelines.html">Ruby on Rails 指南准则</option>
</optgroup>
<optgroup label="维护方针">
<option value="maintenance_policy.html">维护方针</option>
</optgroup>
<optgroup label="发布记">
<option value="upgrading_ruby_on_rails.html">升级 Ruby on Rails</option>
<option value="4_2_release_notes.html">Ruby on Rails 4.2 发布记</option>
<option value="4_1_release_notes.html">Ruby on Rails 4.1 发布记</option>
<option value="4_0_release_notes.html">Ruby on Rails 4.0 发布记</option>
<option value="3_2_release_notes.html">Ruby on Rails 3.2 发布记</option>
<option value="3_1_release_notes.html">Ruby on Rails 3.1 发布记</option>
<option value="3_0_release_notes.html">Ruby on Rails 3.0 发布记</option>
<option value="2_3_release_notes.html">Ruby on Rails 2.3 发布记</option>
<option value="2_2_release_notes.html">Ruby on Rails 2.2 发布记</option>
</optgroup>
</select>
</li>
</ul>
</div>
</div>
</div>
<hr class="hide" />
<div id="feature">
<div class="wrapper">
<h2>Ruby on Rails 3.2 Release Notes</h2><p>Highlights in Rails 3.2:</p>
<ul>
<li>Faster Development Mode</li>
<li>New Routing Engine</li>
<li>Automatic Query Explains</li>
<li>Tagged Logging</li>
</ul>
<p>These release notes cover the major changes, but do not include each bug-fix and changes. If you want to see everything, check out the <a href="https://github.com/rails/rails/commits/3-2-stable">list of commits</a> in the main Rails repository on GitHub.</p>
<div id="subCol">
<h3 class="chapter"><img src="images/chapters_icon.gif" alt="" />Chapters</h3>
<ol class="chapters">
<li>
<a href="#upgrading-to-rails-3.2">Upgrading to Rails 3.2</a>
<ul>
<li><a href="#rails-3.2-requires-at-least-ruby-1.8.7">Rails 3.2 requires at least Ruby 1.8.7</a></li>
<li><a href="#what-to-update-in-your-apps">What to update in your apps</a></li>
<li><a href="#what-to-update-in-your-engines">What to update in your engines</a></li>
</ul>
</li>
<li>
<a href="#creating-a-rails-3.2-application">Creating a Rails 3.2 application</a>
<ul>
<li><a href="#vendoring-gems">Vendoring Gems</a></li>
<li><a href="#living-on-the-edge">Living on the Edge</a></li>
</ul>
</li>
<li>
<a href="#major-features">Major Features</a>
<ul>
<li><a href="#faster-development-mode-&-routing">Faster Development Mode & Routing</a></li>
<li><a href="#automatic-query-explains">Automatic Query Explains</a></li>
<li><a href="#tagged-logging">Tagged Logging</a></li>
</ul>
</li>
<li><a href="#documentation">Documentation</a></li>
<li><a href="#railties">Railties</a></li>
<li><a href="#action-mailer">Action Mailer</a></li>
<li>
<a href="#action-pack">Action Pack</a>
<ul>
<li><a href="#action-controller">Action Controller</a></li>
<li><a href="#action-dispatch">Action Dispatch</a></li>
<li><a href="#action-view">Action View</a></li>
<li><a href="#sprockets">Sprockets</a></li>
</ul>
</li>
<li>
<a href="#active-record">Active Record</a>
<ul>
<li><a href="#active-record-deprecations">Deprecations</a></li>
</ul>
</li>
<li>
<a href="#active-model">Active Model</a>
<ul>
<li><a href="#active-model-deprecations">Deprecations</a></li>
</ul>
</li>
<li><a href="#active-resource">Active Resource</a></li>
<li>
<a href="#active-support">Active Support</a>
<ul>
<li><a href="#deprecations">Deprecations</a></li>
</ul>
</li>
<li><a href="#credits">Credits</a></li>
</ol>
</div>
</div>
</div>
<div id="container">
<div class="wrapper">
<div id="mainCol">
<h3 id="upgrading-to-rails-3.2">1 Upgrading to Rails 3.2</h3><p>If you're upgrading an existing application, it's a great idea to have good test coverage before going in. You should also first upgrade to Rails 3.1 in case you haven't and make sure your application still runs as expected before attempting an update to Rails 3.2. Then take heed of the following changes:</p><h4 id="rails-3.2-requires-at-least-ruby-1.8.7">1.1 Rails 3.2 requires at least Ruby 1.8.7</h4><p>Rails 3.2 requires Ruby 1.8.7 or higher. Support for all of the previous Ruby versions has been dropped officially and you should upgrade as early as possible. Rails 3.2 is also compatible with Ruby 1.9.2.</p><div class="info"><p>Note that Ruby 1.8.7 p248 and p249 have marshalling bugs that crash Rails. Ruby Enterprise Edition has these fixed since the release of 1.8.7-2010.02. On the 1.9 front, Ruby 1.9.1 is not usable because it outright segfaults, so if you want to use 1.9.x, jump on to 1.9.2 or 1.9.3 for smooth sailing.</p></div><h4 id="what-to-update-in-your-apps">1.2 What to update in your apps</h4>
<ul>
<li>
<p>Update your Gemfile to depend on</p>
<ul>
<li><code>rails = 3.2.0</code></li>
<li><code>sass-rails ~> 3.2.3</code></li>
<li><code>coffee-rails ~> 3.2.1</code></li>
<li><code>uglifier >= 1.0.3</code></li>
</ul>
</li>
<li><p>Rails 3.2 deprecates <code>vendor/plugins</code> and Rails 4.0 will remove them completely. You can start replacing these plugins by extracting them as gems and adding them in your Gemfile. If you choose not to make them gems, you can move them into, say, <code>lib/my_plugin/*</code> and add an appropriate initializer in <code>config/initializers/my_plugin.rb</code>.</p></li>
<li>
<p>There are a couple of new configuration changes you'd want to add in <code>config/environments/development.rb</code>:</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
config.active_record.auto_explain_threshold_in_seconds = 0.5
</pre>
</div>
<p>The <code>mass_assignment_sanitizer</code> config also needs to be added in <code>config/environments/test.rb</code>:</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict
</pre>
</div>
</li>
</ul>
<h4 id="what-to-update-in-your-engines">1.3 What to update in your engines</h4><p>Replace the code beneath the comment in <code>script/rails</code> with the following content:</p><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/your_engine_name/engine', __FILE__)
require 'rails/all'
require 'rails/engine/commands'
</pre>
</div>
<h3 id="creating-a-rails-3.2-application">2 Creating a Rails 3.2 application</h3><div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
# You should have the 'rails' RubyGem installed
$ rails new myapp
$ cd myapp
</pre>
</div>
<h4 id="vendoring-gems">2.1 Vendoring Gems</h4><p>Rails now uses a <code>Gemfile</code> in the application root to determine the gems you require for your application to start. This <code>Gemfile</code> is processed by the <a href="https://github.com/carlhuda/bundler">Bundler</a> gem, which then installs all your dependencies. It can even install all the dependencies locally to your application so that it doesn't depend on the system gems.</p><p>More information: <a href="http://gembundler.com">Bundler homepage</a></p><h4 id="living-on-the-edge">2.2 Living on the Edge</h4><p><code>Bundler</code> and <code>Gemfile</code> makes freezing your Rails application easy as pie with the new dedicated <code>bundle</code> command. If you want to bundle straight from the Git repository, you can pass the <code>--edge</code> flag:</p><div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
$ rails new myapp --edge
</pre>
</div>
<p>If you have a local checkout of the Rails repository and want to generate an application using that, you can pass the <code>--dev</code> flag:</p><div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
$ ruby /path/to/rails/railties/bin/rails new myapp --dev
</pre>
</div>
<h3 id="major-features">3 Major Features</h3><h4 id="faster-development-mode-&-routing">3.1 Faster Development Mode & Routing</h4><p>Rails 3.2 comes with a development mode that's noticeably faster. Inspired by <a href="https://github.com/paneq/active_reload">Active Reload</a>, Rails reloads classes only when files actually change. The performance gains are dramatic on a larger application. Route recognition also got a bunch faster thanks to the new <a href="https://github.com/rails/journey">Journey</a> engine.</p><h4 id="automatic-query-explains">3.2 Automatic Query Explains</h4><p>Rails 3.2 comes with a nice feature that explains queries generated by Arel by defining an <code>explain</code> method in <code>ActiveRecord::Relation</code>. For example, you can run something like <code>puts Person.active.limit(5).explain</code> and the query Arel produces is explained. This allows to check for the proper indexes and further optimizations.</p><p>Queries that take more than half a second to run are <em>automatically</em> explained in the development mode. This threshold, of course, can be changed.</p><h4 id="tagged-logging">3.3 Tagged Logging</h4><p>When running a multi-user, multi-account application, it's a great help to be able to filter the log by who did what. TaggedLogging in Active Support helps in doing exactly that by stamping log lines with subdomains, request ids, and anything else to aid debugging such applications.</p><h3 id="documentation">4 Documentation</h3><p>From Rails 3.2, the Rails guides are available for the Kindle and free Kindle Reading Apps for the iPad, iPhone, Mac, Android, etc.</p><h3 id="railties">5 Railties</h3>
<ul>
<li><p>Speed up development by only reloading classes if dependencies files changed. This can be turned off by setting <code>config.reload_classes_only_on_change</code> to false.</p></li>
<li><p>New applications get a flag <code>config.active_record.auto_explain_threshold_in_seconds</code> in the environments configuration files. With a value of <code>0.5</code> in <code>development.rb</code> and commented out in <code>production.rb</code>. No mention in <code>test.rb</code>.</p></li>
<li><p>Added <code>config.exceptions_app</code> to set the exceptions application invoked by the <code>ShowException</code> middleware when an exception happens. Defaults to <code>ActionDispatch::PublicExceptions.new(Rails.public_path)</code>.</p></li>
<li><p>Added a <code>DebugExceptions</code> middleware which contains features extracted from <code>ShowExceptions</code> middleware.</p></li>
<li><p>Display mounted engines' routes in <code>rake routes</code>.</p></li>
<li>
<p>Allow to change the loading order of railties with <code>config.railties_order</code> like:</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
config.railties_order = [Blog::Engine, :main_app, :all]
</pre>
</div>
</li>
<li><p>Scaffold returns 204 No Content for API requests without content. This makes scaffold work with jQuery out of the box.</p></li>
<li><p>Update <code>Rails::Rack::Logger</code> middleware to apply any tags set in <code>config.log_tags</code> to <code>ActiveSupport::TaggedLogging</code>. This makes it easy to tag log lines with debug information like subdomain and request id -- both very helpful in debugging multi-user production applications.</p></li>
<li><p>Default options to <code>rails new</code> can be set in <code>~/.railsrc</code>. You can specify extra command-line arguments to be used every time <code>rails new</code> runs in the <code>.railsrc</code> configuration file in your home directory.</p></li>
<li><p>Add an alias <code>d</code> for <code>destroy</code>. This works for engines too.</p></li>
<li><p>Attributes on scaffold and model generators default to string. This allows the following: <code>rails g scaffold Post title body:text author</code></p></li>
<li>
<p>Allow scaffold/model/migration generators to accept "index" and "uniq" modifiers. For example,</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
rails g scaffold Post title:string:index author:uniq price:decimal{7,2}
</pre>
</div>
<p>will create indexes for <code>title</code> and <code>author</code> with the latter being an unique index. Some types such as decimal accept custom options. In the example, <code>price</code> will be a decimal column with precision and scale set to 7 and 2 respectively.</p>
</li>
<li><p>Turn gem has been removed from default Gemfile.</p></li>
<li><p>Remove old plugin generator <code>rails generate plugin</code> in favor of <code>rails plugin new</code> command.</p></li>
<li><p>Remove old <code>config.paths.app.controller</code> API in favor of <code>config.paths["app/controller"]</code>.</p></li>
</ul>
<h5 id="railties-deprecations">5.1 Deprecations</h5>
<ul>
<li>
<code>Rails::Plugin</code> is deprecated and will be removed in Rails 4.0. Instead of adding plugins to <code>vendor/plugins</code> use gems or bundler with path or git dependencies.</li>
</ul>
<h3 id="action-mailer">6 Action Mailer</h3>
<ul>
<li><p>Upgraded <code>mail</code> version to 2.4.0.</p></li>
<li><p>Removed the old Action Mailer API which was deprecated since Rails 3.0.</p></li>
</ul>
<h3 id="action-pack">7 Action Pack</h3><h4 id="action-controller">7.1 Action Controller</h4>
<ul>
<li><p>Make <code>ActiveSupport::Benchmarkable</code> a default module for <code>ActionController::Base,</code> so the <code>#benchmark</code> method is once again available in the controller context like it used to be.</p></li>
<li><p>Added <code>:gzip</code> option to <code>caches_page</code>. The default option can be configured globally using <code>page_cache_compression</code>.</p></li>
<li>
<p>Rails will now use your default layout (such as "layouts/application") when you specify a layout with <code>:only</code> and <code>:except</code> condition, and those conditions fail.</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
class CarsController
layout 'single_car', :only => :show
end
</pre>
</div>
<p>Rails will use <code>layouts/single_car</code> when a request comes in <code>:show</code> action, and use <code>layouts/application</code> (or <code>layouts/cars</code>, if exists) when a request comes in for any other actions.</p>
</li>
<li><p><code>form_for</code> is changed to use <code>#{action}_#{as}</code> as the css class and id if <code>:as</code> option is provided. Earlier versions used <code>#{as}_#{action}</code>.</p></li>
<li><p><code>ActionController::ParamsWrapper</code> on Active Record models now only wrap <code>attr_accessible</code> attributes if they were set. If not, only the attributes returned by the class method <code>attribute_names</code> will be wrapped. This fixes the wrapping of nested attributes by adding them to <code>attr_accessible</code>.</p></li>
<li><p>Log "Filter chain halted as CALLBACKNAME rendered or redirected" every time a before callback halts.</p></li>
<li><p><code>ActionDispatch::ShowExceptions</code> is refactored. The controller is responsible for choosing to show exceptions. It's possible to override <code>show_detailed_exceptions?</code> in controllers to specify which requests should provide debugging information on errors.</p></li>
<li><p>Responders now return 204 No Content for API requests without a response body (as in the new scaffold).</p></li>
<li>
<p><code>ActionController::TestCase</code> cookies is refactored. Assigning cookies for test cases should now use <code>cookies[]</code></p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
cookies[:email] = '[email protected]'
get :index
assert_equal '[email protected]', cookies[:email]
</pre>
</div>
<p>To clear the cookies, use <code>clear</code>.</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
cookies.clear
get :index
assert_nil cookies[:email]
</pre>
</div>
<p>We now no longer write out HTTP_COOKIE and the cookie jar is persistent between requests so if you need to manipulate the environment for your test you need to do it before the cookie jar is created.</p>
</li>
<li><p><code>send_file</code> now guesses the MIME type from the file extension if <code>:type</code> is not provided.</p></li>
<li><p>MIME type entries for PDF, ZIP and other formats were added.</p></li>
<li><p>Allow <code>fresh_when/stale?</code> to take a record instead of an options hash.</p></li>
<li><p>Changed log level of warning for missing CSRF token from <code>:debug</code> to <code>:warn</code>.</p></li>
<li><p>Assets should use the request protocol by default or default to relative if no request is available.</p></li>
</ul>
<h5 id="action-controller-deprecations">7.1.1 Deprecations</h5>
<ul>
<li>
<p>Deprecated implied layout lookup in controllers whose parent had an explicit layout set:</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
class ApplicationController
layout "application"
end
class PostsController < ApplicationController
end
</pre>
</div>
<p>In the example above, <code>PostsController</code> will no longer automatically look up for a posts layout. If you need this functionality you could either remove <code>layout "application"</code> from <code>ApplicationController</code> or explicitly set it to <code>nil</code> in <code>PostsController</code>.</p>
</li>
<li><p>Deprecated <code>ActionController::UnknownAction</code> in favor of <code>AbstractController::ActionNotFound</code>.</p></li>
<li><p>Deprecated <code>ActionController::DoubleRenderError</code> in favor of <code>AbstractController::DoubleRenderError</code>.</p></li>
<li><p>Deprecated <code>method_missing</code> in favor of <code>action_missing</code> for missing actions.</p></li>
<li><p>Deprecated <code>ActionController#rescue_action</code>, <code>ActionController#initialize_template_class</code> and <code>ActionController#assign_shortcuts</code>.</p></li>
</ul>
<h4 id="action-dispatch">7.2 Action Dispatch</h4>
<ul>
<li><p>Add <code>config.action_dispatch.default_charset</code> to configure default charset for <code>ActionDispatch::Response</code>.</p></li>
<li><p>Added <code>ActionDispatch::RequestId</code> middleware that'll make a unique X-Request-Id header available to the response and enables the <code>ActionDispatch::Request#uuid</code> method. This makes it easy to trace requests from end-to-end in the stack and to identify individual requests in mixed logs like Syslog.</p></li>
<li><p>The <code>ShowExceptions</code> middleware now accepts an exceptions application that is responsible to render an exception when the application fails. The application is invoked with a copy of the exception in <code>env["action_dispatch.exception"]</code> and with the <code>PATH_INFO</code> rewritten to the status code.</p></li>
<li><p>Allow rescue responses to be configured through a railtie as in <code>config.action_dispatch.rescue_responses</code>.</p></li>
</ul>
<h5 id="action-dispatch-deprecations">7.2.1 Deprecations</h5>
<ul>
<li>Deprecated the ability to set a default charset at the controller level, use the new <code>config.action_dispatch.default_charset</code> instead.</li>
</ul>
<h4 id="action-view">7.3 Action View</h4>
<ul>
<li>
<p>Add <code>button_tag</code> support to <code>ActionView::Helpers::FormBuilder</code>. This support mimics the default behavior of <code>submit_tag</code>.</p>
<div class="code_container">
<pre class="brush: ruby; html-script: true; gutter: false; toolbar: false">
<%= form_for @post do |f| %>
<%= f.button %>
<% end %>
</pre>
</div>
</li>
<li><p>Date helpers accept a new option <code>:use_two_digit_numbers => true</code>, that renders select boxes for months and days with a leading zero without changing the respective values. For example, this is useful for displaying ISO 8601-style dates such as '2011-08-01'.</p></li>
<li>
<p>You can provide a namespace for your form to ensure uniqueness of id attributes on form elements. The namespace attribute will be prefixed with underscore on the generated HTML id.</p>
<div class="code_container">
<pre class="brush: ruby; html-script: true; gutter: false; toolbar: false">
<%= form_for(@offer, :namespace => 'namespace') do |f| %>
<%= f.label :version, 'Version' %>:
<%= f.text_field :version %>
<% end %>
</pre>
</div>
</li>
<li><p>Limit the number of options for <code>select_year</code> to 1000. Pass <code>:max_years_allowed</code> option to set your own limit.</p></li>
<li>
<p><code>content_tag_for</code> and <code>div_for</code> can now take a collection of records. It will also yield the record as the first argument if you set a receiving argument in your block. So instead of having to do this:</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
@items.each do |item|
content_tag_for(:li, item) do
Title: <%= item.title %>
end
end
</pre>
</div>
<p>You can do this:</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
content_tag_for(:li, @items) do |item|
Title: <%= item.title %>
end
</pre>
</div>
</li>
<li><p>Added <code>font_path</code> helper method that computes the path to a font asset in <code>public/fonts</code>.</p></li>
</ul>
<h5 id="action-view-deprecations">7.3.1 Deprecations</h5>
<ul>
<li>Passing formats or handlers to render :template and friends like <code>render :template => "foo.html.erb"</code> is deprecated. Instead, you can provide :handlers and :formats directly as options: <code>render :template => "foo", :formats => [:html, :js], :handlers => :erb</code>.</li>
</ul>
<h4 id="sprockets">7.4 Sprockets</h4>
<ul>
<li>Adds a configuration option <code>config.assets.logger</code> to control Sprockets logging. Set it to <code>false</code> to turn off logging and to <code>nil</code> to default to <code>Rails.logger</code>.</li>
</ul>
<h3 id="active-record">8 Active Record</h3>
<ul>
<li><p>Boolean columns with 'on' and 'ON' values are type cast to true.</p></li>
<li><p>When the <code>timestamps</code> method creates the <code>created_at</code> and <code>updated_at</code> columns, it makes them non-nullable by default.</p></li>
<li><p>Implemented <code>ActiveRecord::Relation#explain</code>.</p></li>
<li><p>Implements <code>AR::Base.silence_auto_explain</code> which allows the user to selectively disable automatic EXPLAINs within a block.</p></li>
<li><p>Implements automatic EXPLAIN logging for slow queries. A new configuration parameter <code>config.active_record.auto_explain_threshold_in_seconds</code> determines what's to be considered a slow query. Setting that to nil disables this feature. Defaults are 0.5 in development mode, and nil in test and production modes. Rails 3.2 supports this feature in SQLite, MySQL (mysql2 adapter), and PostgreSQL.</p></li>
<li>
<p>Added <code>ActiveRecord::Base.store</code> for declaring simple single-column key/value stores.</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
class User < ActiveRecord::Base
store :settings, accessors: [ :color, :homepage ]
end
u = User.new(color: 'black', homepage: '37signals.com')
u.color # Accessor stored attribute
u.settings[:country] = 'Denmark' # Any attribute, even if not specified with an accessor
</pre>
</div>
</li>
<li>
<p>Added ability to run migrations only for a given scope, which allows to run migrations only from one engine (for example to revert changes from an engine that need to be removed).</p>
<div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
rake db:migrate SCOPE=blog
</pre>
</div>
</li>
<li><p>Migrations copied from engines are now scoped with engine's name, for example <code>01_create_posts.blog.rb</code>.</p></li>
<li>
<p>Implemented <code>ActiveRecord::Relation#pluck</code> method that returns an array of column values directly from the underlying table. This also works with serialized attributes.</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
Client.where(:active => true).pluck(:id)
# SELECT id from clients where active = 1
</pre>
</div>
</li>
<li><p>Generated association methods are created within a separate module to allow overriding and composition. For a class named MyModel, the module is named <code>MyModel::GeneratedFeatureMethods</code>. It is included into the model class immediately after the <code>generated_attributes_methods</code> module defined in Active Model, so association methods override attribute methods of the same name.</p></li>
<li>
<p>Add <code>ActiveRecord::Relation#uniq</code> for generating unique queries.</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
Client.select('DISTINCT name')
</pre>
</div>
<p>..can be written as:</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
Client.select(:name).uniq
</pre>
</div>
<p>This also allows you to revert the uniqueness in a relation:</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
Client.select(:name).uniq.uniq(false)
</pre>
</div>
</li>
<li><p>Support index sort order in SQLite, MySQL and PostgreSQL adapters.</p></li>
<li>
<p>Allow the <code>:class_name</code> option for associations to take a symbol in addition to a string. This is to avoid confusing newbies, and to be consistent with the fact that other options like <code>:foreign_key</code> already allow a symbol or a string.</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
has_many :clients, :class_name => :Client # Note that the symbol need to be capitalized
</pre>
</div>
</li>
<li><p>In development mode, <code>db:drop</code> also drops the test database in order to be symmetric with <code>db:create</code>.</p></li>
<li><p>Case-insensitive uniqueness validation avoids calling LOWER in MySQL when the column already uses a case-insensitive collation.</p></li>
<li><p>Transactional fixtures enlist all active database connections. You can test models on different connections without disabling transactional fixtures.</p></li>
<li>
<p>Add <code>first_or_create</code>, <code>first_or_create!</code>, <code>first_or_initialize</code> methods to Active Record. This is a better approach over the old <code>find_or_create_by</code> dynamic methods because it's clearer which arguments are used to find the record and which are used to create it.</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
User.where(:first_name => "Scarlett").first_or_create!(:last_name => "Johansson")
</pre>
</div>
</li>
<li>
<p>Added a <code>with_lock</code> method to Active Record objects, which starts a transaction, locks the object (pessimistically) and yields to the block. The method takes one (optional) parameter and passes it to <code>lock!</code>.</p>
<p>This makes it possible to write the following:</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
class Order < ActiveRecord::Base
def cancel!
transaction do
lock!
# ... cancelling logic
end
end
end
</pre>
</div>
<p>as:</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
class Order < ActiveRecord::Base
def cancel!
with_lock do
# ... cancelling logic
end
end
end
</pre>
</div>
</li>
</ul>
<h4 id="active-record-deprecations">8.1 Deprecations</h4>
<ul>
<li>
<p>Automatic closure of connections in threads is deprecated. For example the following code is deprecated:</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
Thread.new { Post.find(1) }.join
</pre>
</div>
<p>It should be changed to close the database connection at the end of the thread:</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
Thread.new {
Post.find(1)
Post.connection.close
}.join
</pre>
</div>
<p>Only people who spawn threads in their application code need to worry about this change.</p>
</li>
<li>
<p>The <code>set_table_name</code>, <code>set_inheritance_column</code>, <code>set_sequence_name</code>, <code>set_primary_key</code>, <code>set_locking_column</code> methods are deprecated. Use an assignment method instead. For example, instead of <code>set_table_name</code>, use <code>self.table_name=</code>.</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
class Project < ActiveRecord::Base
self.table_name = "project"
end
</pre>
</div>
<p>Or define your own <code>self.table_name</code> method:</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
class Post < ActiveRecord::Base
def self.table_name
"special_" + super
end
end
Post.table_name # => "special_posts"
</pre>
</div>
</li>
</ul>
<h3 id="active-model">9 Active Model</h3>
<ul>
<li><p>Add <code>ActiveModel::Errors#added?</code> to check if a specific error has been added.</p></li>
<li><p>Add ability to define strict validations with <code>strict => true</code> that always raises exception when fails.</p></li>
<li><p>Provide mass_assignment_sanitizer as an easy API to replace the sanitizer behavior. Also support both :logger (default) and :strict sanitizer behavior.</p></li>
</ul>
<h4 id="active-model-deprecations">9.1 Deprecations</h4>
<ul>
<li><p>Deprecated <code>define_attr_method</code> in <code>ActiveModel::AttributeMethods</code> because this only existed to support methods like <code>set_table_name</code> in Active Record, which are themselves being deprecated.</p></li>
<li><p>Deprecated <code>Model.model_name.partial_path</code> in favor of <code>model.to_partial_path</code>.</p></li>
</ul>
<h3 id="active-resource">10 Active Resource</h3>
<ul>
<li>Redirect responses: 303 See Other and 307 Temporary Redirect now behave like 301 Moved Permanently and 302 Found.</li>
</ul>
<h3 id="active-support">11 Active Support</h3>
<ul>
<li>
<p>Added <code>ActiveSupport:TaggedLogging</code> that can wrap any standard <code>Logger</code> class to provide tagging capabilities.</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
Logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
Logger.tagged("BCX") { Logger.info "Stuff" }
# Logs "[BCX] Stuff"
Logger.tagged("BCX", "Jason") { Logger.info "Stuff" }
# Logs "[BCX] [Jason] Stuff"
Logger.tagged("BCX") { Logger.tagged("Jason") { Logger.info "Stuff" } }
# Logs "[BCX] [Jason] Stuff"
</pre>
</div>
</li>
<li><p>The <code>beginning_of_week</code> method in <code>Date</code>, <code>Time</code> and <code>DateTime</code> accepts an optional argument representing the day in which the week is assumed to start.</p></li>
<li><p><code>ActiveSupport::Notifications.subscribed</code> provides subscriptions to events while a block runs.</p></li>
<li><p>Defined new methods <code>Module#qualified_const_defined?</code>, <code>Module#qualified_const_get</code> and <code>Module#qualified_const_set</code> that are analogous to the corresponding methods in the standard API, but accept qualified constant names.</p></li>
<li><p>Added <code>#deconstantize</code> which complements <code>#demodulize</code> in inflections. This removes the rightmost segment in a qualified constant name.</p></li>
<li><p>Added <code>safe_constantize</code> that constantizes a string but returns <code>nil</code> instead of raising an exception if the constant (or part of it) does not exist.</p></li>
<li><p><code>ActiveSupport::OrderedHash</code> is now marked as extractable when using <code>Array#extract_options!</code>.</p></li>
<li><p>Added <code>Array#prepend</code> as an alias for <code>Array#unshift</code> and <code>Array#append</code> as an alias for <code>Array#<<</code>.</p></li>
<li><p>The definition of a blank string for Ruby 1.9 has been extended to Unicode whitespace. Also, in Ruby 1.8 the ideographic space U`3000 is considered to be whitespace.</p></li>
<li><p>The inflector understands acronyms.</p></li>
<li>
<p>Added <code>Time#all_day</code>, <code>Time#all_week</code>, <code>Time#all_quarter</code> and <code>Time#all_year</code> as a way of generating ranges.</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
Event.where(:created_at => Time.now.all_week)
Event.where(:created_at => Time.now.all_day)
</pre>
</div>
</li>
<li><p>Added <code>instance_accessor: false</code> as an option to <code>Class#cattr_accessor</code> and friends.</p></li>
<li><p><code>ActiveSupport::OrderedHash</code> now has different behavior for <code>#each</code> and <code>#each_pair</code> when given a block accepting its parameters with a splat.</p></li>
<li><p>Added <code>ActiveSupport::Cache::NullStore</code> for use in development and testing.</p></li>
<li><p>Removed <code>ActiveSupport::SecureRandom</code> in favor of <code>SecureRandom</code> from the standard library.</p></li>
</ul>
<h4 id="deprecations">11.1 Deprecations</h4>
<ul>
<li><p><code>ActiveSupport::Base64</code> is deprecated in favor of <code>::Base64</code>.</p></li>
<li><p>Deprecated <code>ActiveSupport::Memoizable</code> in favor of Ruby memoization pattern.</p></li>
<li><p><code>Module#synchronize</code> is deprecated with no replacement. Please use monitor from ruby's standard library.</p></li>
<li><p>Deprecated <code>ActiveSupport::MessageEncryptor#encrypt</code> and <code>ActiveSupport::MessageEncryptor#decrypt</code>.</p></li>
<li><p><code>ActiveSupport::BufferedLogger#silence</code> is deprecated. If you want to squelch logs for a certain block, change the log level for that block.</p></li>
<li><p><code>ActiveSupport::BufferedLogger#open_log</code> is deprecated. This method should not have been public in the first place.</p></li>
<li><p><code>ActiveSupport::BufferedLogger's</code> behavior of automatically creating the directory for your log file is deprecated. Please make sure to create the directory for your log file before instantiating.</p></li>
<li>
<p><code>ActiveSupport::BufferedLogger#auto_flushing</code> is deprecated. Either set the sync level on the underlying file handle like this. Or tune your filesystem. The FS cache is now what controls flushing.</p>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
f = File.open('foo.log', 'w')
f.sync = true
ActiveSupport::BufferedLogger.new f
</pre>
</div>
</li>
<li><p><code>ActiveSupport::BufferedLogger#flush</code> is deprecated. Set sync on your filehandle, or tune your filesystem.</p></li>
</ul>
<h3 id="credits">12 Credits</h3><p>See the <a href="http://contributors.rubyonrails.org/">full list of contributors to Rails</a> for the many people who spent many hours making Rails, the stable and robust framework it is. Kudos to all of them.</p><p>Rails 3.2 Release Notes were compiled by <a href="https://github.com/vijaydev">Vijay Dev</a>.</p>
<h3>反馈</h3>
<p>
欢迎帮忙改善指南质量。
</p>
<p>
如发现任何错误,欢迎修正。开始贡献前,可先行阅读<a href="http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#contributing-to-the-rails-documentation">贡献指南:文档</a>。
</p>
<p>翻译如有错误,深感抱歉,欢迎 <a href="https://github.com/ruby-china/guides/fork">Fork</a> 修正,或至此处<a href="https://github.com/ruby-china/guides/issues/new">回报</a>。</p>
<p>
文章可能有未完成或过时的内容。请先检查 <a href="http://edgeguides.rubyonrails.org">Edge Guides</a> 来确定问题在 master 是否已经修掉了。再上 master 补上缺少的文件。内容参考 <a href="ruby_on_rails_guides_guidelines.html">Ruby on Rails 指南准则</a>来了解行文风格。
</p>
<p>最后,任何关于 Ruby on Rails 文档的讨论,欢迎到 <a href="http://groups.google.com/group/rubyonrails-docs">rubyonrails-docs 邮件群组</a>。
</p>
</div>
</div>
</div>
<hr class="hide" />
<div id="footer">
<div class="wrapper">
<p>本著作采用<a href="https://creativecommons.org/licenses/by-sa/4.0/">创用 CC 姓名标示-相同方式分享 4.0 国际授权条款</a>授权。</p>
<p>“Rails”、“Ruby on Rails”,以及 Rails logo 为 David Heinemeier Hansson 的商标。版权所有。</p>
</div>
</div>
<script type="text/javascript" src="javascripts/jquery.min.js"></script>
<script type="text/javascript" src="javascripts/responsive-tables.js"></script>
<script type="text/javascript" src="javascripts/guides.js"></script>
<script type="text/javascript" src="javascripts/syntaxhighlighter/shCore.js"></script>
<script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushRuby.js"></script>
<script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushXml.js"></script>
<script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushSql.js"></script>
<script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushPlain.js"></script>
<script type="text/javascript">
SyntaxHighlighter.all();
$(guidesIndex.bind);
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
// ga('create', '', 'ruby-china.github.io');
ga('require', 'displayfeatures');
ga('send', 'pageview');
</script>
</body>
</html>